MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / MutableDataPoint

Class MutableDataPoint

src/core/MutableDataPoint.java:19–150  ·  view source on GitHub ↗

A mutable DataPoint that stores a value and a timestamp.

Source from the content-addressed store, hash-verified

17 * A mutable {@link DataPoint} that stores a value and a timestamp.
18 */
19public final class MutableDataPoint implements DataPoint {
20
21 // NOTE: Fields are not final to make an instance available to store a new
22 // pair of a timestamp and a value to reduce memory burden.
23 /** The timestamp of the value. */
24 private long timestamp = Long.MAX_VALUE;
25 /** True if the value is stored as a long. */
26 private boolean is_integer = true;
27 /** A long value or a double encoded on a long if {@code is_integer} is false. */
28 private long value = 0;
29
30 /**
31 * Resets with a new pair of a timestamp and a double value.
32 *
33 * @param timestamp A timestamp.
34 * @param value A double value.
35 */
36 public void reset(final long timestamp, final double value) {
37 this.timestamp = timestamp;
38 this.is_integer = false;
39 this.value = Double.doubleToRawLongBits(value);
40 }
41
42 /**
43 * Resets with a new pair of a timestamp and a long value.
44 *
45 * @param timestamp A timestamp.
46 * @param value A double value.
47 */
48 public void reset(final long timestamp, final long value) {
49 this.timestamp = timestamp;
50 this.is_integer = true;
51 this.value = value;
52 }
53
54 /**
55 * Resets with a new data point.
56 *
57 * @param dp A new data point to store.
58 */
59 public void reset(DataPoint dp) {
60 this.timestamp = dp.timestamp();
61 this.is_integer = dp.isInteger();
62 if (is_integer) {
63 this.value = dp.longValue();
64 } else {
65 this.value = Double.doubleToRawLongBits(dp.doubleValue());
66 }
67 }
68
69 /**
70 * Resets with a new pair of a timestamp and a double value.
71 *
72 * @param timestamp A timestamp.
73 * @param value A double value.
74 */
75 public static MutableDataPoint ofDoubleValue(final long timestamp,
76 final double value) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…