Fix the flags inside the last byte of a qualifier. OpenTSDB used to not rely on the size recorded in the flags being correct, and so for a long time it was setting the wrong size for floating point values (pretending they were encoded on 8 bytes when in fact they were on 4). So overwrite these
(byte flags, final int val_len)
| 533 | * @return The least significant byte of the qualifier with correct flags. |
| 534 | */ |
| 535 | public static byte fixQualifierFlags(byte flags, final int val_len) { |
| 536 | // Explanation: |
| 537 | // (1) Take the last byte of the qualifier. |
| 538 | // (2) Zero out all the flag bits but one. |
| 539 | // The one we keep is the type (floating point vs integer value). |
| 540 | // (3) Set the length properly based on the value we have. |
| 541 | return (byte) ((flags & ~(Const.FLAGS_MASK >>> 1)) | (val_len - 1)); |
| 542 | // ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ |
| 543 | // (1) (2) (3) |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * Returns whether or not this is a floating value that needs to be fixed. |
no outgoing calls