@Override protected Object getAverage(Interval interval) { Double average = getAverageDouble(interval); return average != null ? average : null; }
@Override protected Object getMax(Interval interval) { Double max = getMaxDouble(interval); return max != null ? max.byteValue() : null; }
@Override protected Object getMin(Interval interval) { Double min = getMinDouble(interval); return min != null ? min.byteValue() : null; }
/** * Get the value for the given interval. * * @param interval interval * @return found value or the default value if not found * @throws IllegalArgumentException if the element doesn't exist */ public byte getByte(Interval interval) { final int index = getIndex(interval.getLow(), interval.getHigh()); if (index >= 0) { return values[index / 2]; } throw new IllegalArgumentException("The element doesn't exist"); }
private IntervalMap deserializeIntervalMap(final DataInput is) throws IOException, ClassNotFoundException { double[] intervals = (double[]) deserialize(is); Object values = deserialize(is); Class mapClass = values.getClass(); IntervalMap valueSet; if (mapClass.equals(boolean[].class)) { valueSet = new IntervalBooleanMap(intervals, (boolean[]) values); } else if (mapClass.equals(byte[].class)) { valueSet = new IntervalByteMap(intervals, (byte[]) values); } else if (mapClass.equals(char[].class)) { valueSet = new IntervalCharMap(intervals, (char[]) values); } else if (mapClass.equals(double[].class)) { valueSet = new IntervalDoubleMap(intervals, (double[]) values); } else if (mapClass.equals(float[].class)) { valueSet = new IntervalFloatMap(intervals, (float[]) values); } else if (mapClass.equals(int[].class)) { valueSet = new IntervalIntegerMap(intervals, (int[]) values); } else if (mapClass.equals(long[].class)) { valueSet = new IntervalLongMap(intervals, (long[]) values); } else if (mapClass.equals(short[].class)) { valueSet = new IntervalShortMap(intervals, (short[]) values); } else if (mapClass.equals(String[].class)) { valueSet = new IntervalStringMap(intervals, (String[]) values); } else { throw new RuntimeException("Unrecognized timestamp map class"); } return valueSet; }
/** * Returns an array of all values in this map. * <p> * This method may return a reference to the underlying array so clients * should make a copy if the array is written to. * * @return array of all values */ public byte[] toByteArray() { return (byte[]) toNativeArray(); }
private void serializeIntervalMap(final DataOutput out, final IntervalMap intervalMap) throws IOException { serialize(out, intervalMap.getIntervals()); Class mapClass = intervalMap.getClass(); if (mapClass.equals(IntervalBooleanMap.class)) { serialize(out, ((IntervalBooleanMap) intervalMap).toBooleanArray()); } else if (mapClass.equals(IntervalByteMap.class)) { serialize(out, ((IntervalByteMap) intervalMap).toByteArray()); } else if (mapClass.equals(IntervalCharMap.class)) { serialize(out, ((IntervalCharMap) intervalMap).toCharacterArray()); } else if (mapClass.equals(IntervalDoubleMap.class)) { serialize(out, ((IntervalDoubleMap) intervalMap).toDoubleArray()); } else if (mapClass.equals(IntervalFloatMap.class)) { serialize(out, ((IntervalFloatMap) intervalMap).toFloatArray()); } else if (mapClass.equals(IntervalIntegerMap.class)) { serialize(out, ((IntervalIntegerMap) intervalMap).toIntegerArray()); } else if (mapClass.equals(IntervalLongMap.class)) { serialize(out, ((IntervalLongMap) intervalMap).toLongArray()); } else if (mapClass.equals(IntervalShortMap.class)) { serialize(out, ((IntervalShortMap) intervalMap).toShortArray()); } else if (mapClass.equals(IntervalStringMap.class)) { serialize(out, intervalMap.toValuesArray()); } else { throw new RuntimeException("Unrecognized interval map class"); } }
/** * Get the value for the given interval. * * @param interval interval * @return found value or the default value if not found * @throws IllegalArgumentException if the element doesn't exist */ public byte getByte(Interval interval) { final int index = getIndex(interval.getLow(), interval.getHigh()); if (index >= 0) { return values[index / 2]; } throw new IllegalArgumentException("The element doesn't exist"); }
private IntervalMap deserializeIntervalMap(final DataInput is) throws IOException, ClassNotFoundException { double[] intervals = (double[]) deserialize(is); Object values = deserialize(is); Class mapClass = values.getClass(); IntervalMap valueSet; if (mapClass.equals(boolean[].class)) { valueSet = new IntervalBooleanMap(intervals, (boolean[]) values); } else if (mapClass.equals(byte[].class)) { valueSet = new IntervalByteMap(intervals, (byte[]) values); } else if (mapClass.equals(char[].class)) { valueSet = new IntervalCharMap(intervals, (char[]) values); } else if (mapClass.equals(double[].class)) { valueSet = new IntervalDoubleMap(intervals, (double[]) values); } else if (mapClass.equals(float[].class)) { valueSet = new IntervalFloatMap(intervals, (float[]) values); } else if (mapClass.equals(int[].class)) { valueSet = new IntervalIntegerMap(intervals, (int[]) values); } else if (mapClass.equals(long[].class)) { valueSet = new IntervalLongMap(intervals, (long[]) values); } else if (mapClass.equals(short[].class)) { valueSet = new IntervalShortMap(intervals, (short[]) values); } else if (mapClass.equals(String[].class)) { valueSet = new IntervalStringMap(intervals, (String[]) values); } else { throw new RuntimeException("Unrecognized timestamp map class"); } return valueSet; }
/** * Returns an array of all values in this map. * <p> * This method may return a reference to the underlying array so clients * should make a copy if the array is written to. * * @return array of all values */ public byte[] toByteArray() { return (byte[]) toNativeArray(); }
private void serializeIntervalMap(final DataOutput out, final IntervalMap intervalMap) throws IOException { serialize(out, intervalMap.getIntervals()); Class mapClass = intervalMap.getClass(); if (mapClass.equals(IntervalBooleanMap.class)) { serialize(out, ((IntervalBooleanMap) intervalMap).toBooleanArray()); } else if (mapClass.equals(IntervalByteMap.class)) { serialize(out, ((IntervalByteMap) intervalMap).toByteArray()); } else if (mapClass.equals(IntervalCharMap.class)) { serialize(out, ((IntervalCharMap) intervalMap).toCharacterArray()); } else if (mapClass.equals(IntervalDoubleMap.class)) { serialize(out, ((IntervalDoubleMap) intervalMap).toDoubleArray()); } else if (mapClass.equals(IntervalFloatMap.class)) { serialize(out, ((IntervalFloatMap) intervalMap).toFloatArray()); } else if (mapClass.equals(IntervalIntegerMap.class)) { serialize(out, ((IntervalIntegerMap) intervalMap).toIntegerArray()); } else if (mapClass.equals(IntervalLongMap.class)) { serialize(out, ((IntervalLongMap) intervalMap).toLongArray()); } else if (mapClass.equals(IntervalShortMap.class)) { serialize(out, ((IntervalShortMap) intervalMap).toShortArray()); } else if (mapClass.equals(IntervalStringMap.class)) { serialize(out, intervalMap.toValuesArray()); } else { throw new RuntimeException("Unrecognized interval map class"); } }
/** * Get the value for the given interval. * <p> * Return <code>defaultValue</code> if the value is not found. * * @param interval interval * @param defaultValue default value * @return found value or the default value if not found */ public byte getByte(Interval interval, byte defaultValue) { final int index = getIndex(interval.getLow(), interval.getHigh()); if (index >= 0) { return values[index / 2]; } return defaultValue; }
result = new IntervalStringMap(capacity); } else if (typeClass.equals(Byte.class)) { result = new IntervalByteMap(capacity); } else if (typeClass.equals(Short.class)) { result = new IntervalShortMap(capacity);
@Override protected Object getMax(Interval interval) { Double max = getMaxDouble(interval); return max != null ? max.byteValue() : null; }
@Override protected Object getMin(Interval interval) { Double min = getMinDouble(interval); return min != null ? min.byteValue() : null; }
@Override protected Object getAverage(Interval interval) { Double average = getAverageDouble(interval); return average != null ? average : null; }
/** * Get the value for the given interval. * <p> * Return <code>defaultValue</code> if the value is not found. * * @param interval interval * @param defaultValue default value * @return found value or the default value if not found */ public byte getByte(Interval interval, byte defaultValue) { final int index = getIndex(interval.getLow(), interval.getHigh()); if (index >= 0) { return values[index / 2]; } return defaultValue; }
result = new IntervalStringMap(capacity); } else if (typeClass.equals(Byte.class)) { result = new IntervalByteMap(capacity); } else if (typeClass.equals(Short.class)) { result = new IntervalShortMap(capacity);