Receives new data points and stores them in compacted form. No points are written until flushNow is called. This ensures that true batch dynamics can be leveraged. This implementation will allow an entire hours worth of data to be written in a single transaction to the data table.
| 32 | * worth of data to be written in a single transaction to the data table. |
| 33 | */ |
| 34 | final class BatchedDataPoints implements WritableDataPoints { |
| 35 | |
| 36 | /** |
| 37 | * The {@code TSDB} instance we belong to. |
| 38 | */ |
| 39 | private final TSDB tsdb; |
| 40 | |
| 41 | /** |
| 42 | * The row key. Optional salt + 3 bytes for the metric name, 4 bytes for the |
| 43 | * base timestamp, 6 bytes per tag (3 for the name, 3 for the value). |
| 44 | */ |
| 45 | private byte[] row_key; |
| 46 | |
| 47 | /** |
| 48 | * Track the last timestamp written for this series. |
| 49 | */ |
| 50 | private long last_timestamp; |
| 51 | |
| 52 | /** |
| 53 | * Number of data points in this row. |
| 54 | */ |
| 55 | private int size = 0; |
| 56 | |
| 57 | /** |
| 58 | * Storage of the compacted qualifier. |
| 59 | */ |
| 60 | private byte[] batched_qualifier = new byte[Const.MAX_TIMESPAN * 4]; |
| 61 | |
| 62 | /** |
| 63 | * Storage of the compacted value. |
| 64 | */ |
| 65 | private byte[] batched_value = new byte[Const.MAX_TIMESPAN * 8]; |
| 66 | |
| 67 | /** |
| 68 | * Track the index position where the next qualifier gets written. |
| 69 | */ |
| 70 | private int qualifier_index = 0; |
| 71 | |
| 72 | /** |
| 73 | * Track the index position where the next value gets written. |
| 74 | */ |
| 75 | private int value_index = 0; |
| 76 | |
| 77 | /** |
| 78 | * Track the base time for this batch of points. |
| 79 | */ |
| 80 | private long base_time; |
| 81 | |
| 82 | /** |
| 83 | * Constructor. |
| 84 | * |
| 85 | * @param tsdb The TSDB we belong to. |
| 86 | */ |
| 87 | BatchedDataPoints(final TSDB tsdb, final String metric, |
| 88 | final Map<String, String> tags) { |
| 89 | this.tsdb = tsdb; |
| 90 | setSeries(metric, tags); |
| 91 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…