net.opentsdb.core
public final class Internal extends Object
,____________________________, | This class is reserved for | | OpenTSDB's internal usage! | `----------------------------' \ / \ //\ \ |\___/| / \// \\ /0 0 \__ / // | \ \ / / \/_/ // | \ \
Modifier and Type | Class and Description |
---|---|
static class |
Internal.Cell
Represents a single data point in a row.
|
static class |
Internal.KeyValueComparator
Helper to sort a row with a mixture of millisecond and second data points.
|
Modifier and Type | Field and Description |
---|---|
static short |
FLAG_BITS |
static short |
FLAGS_MASK |
static short |
LENGTH_MASK |
Modifier and Type | Method and Description |
---|---|
static long |
baseTime(TSDB tsdb,
byte[] row)
Extracts the timestamp from a row key.
|
static byte[] |
buildQualifier(long timestamp,
short flags)
Returns a 2 or 4 byte qualifier based on the timestamp and the flags.
|
static int |
compareQualifiers(byte[] a,
int offset_a,
byte[] b,
int offset_b)
Compares two data point byte arrays with offsets.
|
static org.hbase.async.KeyValue |
complexCompact(org.hbase.async.KeyValue kv) |
static ArrayList<Internal.Cell> |
extractDataPoints(ArrayList<org.hbase.async.KeyValue> row,
int estimated_nvalues)
Breaks down all the values in a row into individual
Internal.Cell s sorted on
the qualifier. |
static ArrayList<Internal.Cell> |
extractDataPoints(org.hbase.async.KeyValue column)
Extracts the data points from a single column.
|
static double |
extractFloatingPointValue(byte[] values,
int value_idx,
byte flags) |
static long |
extractIntegerValue(byte[] values,
int value_idx,
byte flags) |
static byte[] |
extractQualifier(byte[] qualifier,
int offset)
Extracts the 2 or 4 byte qualifier from a compacted byte array
|
static byte[] |
fixFloatingPointValue(byte flags,
byte[] value)
Returns a corrected value if this is a floating point value to fix.
|
static byte |
fixQualifierFlags(byte flags,
int val_len)
Fix the flags inside the last byte of a qualifier.
|
static boolean |
floatingPointValueToFix(byte flags,
byte[] value)
Returns whether or not this is a floating value that needs to be fixed.
|
static short |
getFlagsFromQualifier(byte[] qualifier)
Parses the flag bits from the qualifier
|
static short |
getFlagsFromQualifier(byte[] qualifier,
int offset)
Parses the flag bits from the qualifier
|
static int |
getOffsetFromQualifier(byte[] qualifier)
Returns the offset in milliseconds from the row base timestamp from a data
point qualifier
|
static int |
getOffsetFromQualifier(byte[] qualifier,
int offset)
Returns the offset in milliseconds from the row base timestamp from a data
point qualifier at the given offset (for compacted columns)
|
static short |
getQualifierLength(byte[] qualifier)
Returns the length, in bytes, of the qualifier: 2 or 4 bytes
|
static short |
getQualifierLength(byte[] qualifier,
int offset)
Returns the length, in bytes, of the qualifier: 2 or 4 bytes
|
static org.hbase.async.Scanner |
getScanner(Query query) |
static Map<String,String> |
getTags(TSDB tsdb,
byte[] row) |
static long |
getTimestampFromQualifier(byte[] qualifier,
long base_time)
Returns the absolute timestamp of a data point qualifier in milliseconds
|
static long |
getTimestampFromQualifier(byte[] qualifier,
long base_time,
int offset)
Returns the absolute timestamp of a data point qualifier in milliseconds
|
static byte |
getValueLengthFromQualifier(byte[] qualifier)
Returns the length of the value, in bytes, parsed from the qualifier
|
static byte |
getValueLengthFromQualifier(byte[] qualifier,
int offset)
Returns the length of the value, in bytes, parsed from the qualifier
|
static boolean |
inMilliseconds(byte qualifier)
Determines if the qualifier is in milliseconds or not
|
static boolean |
inMilliseconds(byte[] qualifier)
Determines if the qualifier is in milliseconds or not
|
static boolean |
inMilliseconds(byte[] qualifier,
byte offset)
Determines if the qualifier is in milliseconds or not
|
static String |
metricName(TSDB tsdb,
byte[] id) |
static short |
metricWidth(TSDB tsdb) |
static Internal.Cell |
parseSingleValue(org.hbase.async.KeyValue column)
Extracts a Cell from a single data point, fixing potential errors with
the qualifier flags
|
public static final short FLAG_BITS
Const.FLAG_BITS
,
Constant Field Valuespublic static final short LENGTH_MASK
Const.LENGTH_MASK
,
Constant Field Valuespublic static final short FLAGS_MASK
Const.FLAGS_MASK
,
Constant Field Valuespublic static org.hbase.async.Scanner getScanner(Query query)
TsdbQuery.getScanner()
public static String metricName(TSDB tsdb, byte[] id)
RowKey.metricName(net.opentsdb.core.TSDB, byte[])
public static long baseTime(TSDB tsdb, byte[] row)
public static long extractIntegerValue(byte[] values, int value_idx, byte flags)
RowSeq.extractIntegerValue(byte[], int, byte)
public static double extractFloatingPointValue(byte[] values, int value_idx, byte flags)
RowSeq.extractFloatingPointValue(byte[], int, byte)
public static short metricWidth(TSDB tsdb)
TSDB.metrics_width()
public static org.hbase.async.KeyValue complexCompact(org.hbase.async.KeyValue kv)
CompactionQueue.complexCompact(java.util.ArrayList, int, boolean)
public static Internal.Cell parseSingleValue(org.hbase.async.KeyValue column)
column
- The column to parseIllegalDataException
- if the qualifier was not 2 bytes long or
it wasn't a millisecond qualifierpublic static ArrayList<Internal.Cell> extractDataPoints(org.hbase.async.KeyValue column)
column
- The column to parseInternal.Cell
objects. The list may be
empty if the column did not contain a data point.IllegalDataException
- if one of the cells cannot be read because
it's corrupted or in a format we don't understand.public static ArrayList<Internal.Cell> extractDataPoints(ArrayList<org.hbase.async.KeyValue> row, int estimated_nvalues)
Internal.Cell
s sorted on
the qualifier. Columns with non data-point data will be discarded.
Note: This method does not account for duplicate timestamps in
qualifiers.row
- An array of data row columns to parseestimated_nvalues
- Estimate of the number of values to compact.
Used to pre-allocate a collection of the right size, so it's better to
overshoot a bit to avoid re-allocations.Internal.Cell
objects. The list may be
empty if the row did not contain a data point.IllegalDataException
- if one of the cells cannot be read because
it's corrupted or in a format we don't understand.public static int compareQualifiers(byte[] a, int offset_a, byte[] b, int offset_b)
a
- The first byte array to compareoffset_a
- An offset for ab
- The second byte arrayoffset_b
- An offset for bpublic static byte fixQualifierFlags(byte flags, int val_len)
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 bits here to make sure they're correct now, because once they're compacted it's going to be quite hard to tell if the flags are right or wrong, and we need them to be correct to easily decode the values.
flags
- The least significant byte of a qualifier.val_len
- The number of bytes in the value of this qualifier.public static boolean floatingPointValueToFix(byte flags, byte[] value)
OpenTSDB used to encode all floating point values as `float' (4 bytes) but actually store them on 8 bytes, with 4 leading 0 bytes, and flags correctly stating the value was on 4 bytes. (from CompactionQueue)
flags
- The least significant byte of a qualifier.value
- The value that may need to be corrected.public static byte[] fixFloatingPointValue(byte flags, byte[] value)
OpenTSDB used to encode all floating point values as `float' (4 bytes) but actually store them on 8 bytes, with 4 leading 0 bytes, and flags correctly stating the value was on 4 bytes.
This function detects such values and returns a corrected value, without the 4 leading zeros. Otherwise it returns the value unchanged. (from CompactionQueue)
flags
- The least significant byte of a qualifier.value
- The value that may need to be corrected.IllegalDataException
- if the value is malformed.public static boolean inMilliseconds(byte[] qualifier, byte offset)
qualifier
- The qualifier to parseoffset
- An offset from the start of the byte arraypublic static boolean inMilliseconds(byte[] qualifier)
qualifier
- The qualifier to parsepublic static boolean inMilliseconds(byte qualifier)
qualifier
- The first byte of a qualifierpublic static int getOffsetFromQualifier(byte[] qualifier)
qualifier
- The qualifier to parseIllegalArgument
- if the qualifier is null or emptypublic static int getOffsetFromQualifier(byte[] qualifier, int offset)
qualifier
- The qualifier to parseoffset
- An offset within the byte arrayIllegalDataException
- if the qualifier is null or the offset falls
outside of the qualifier arraypublic static byte getValueLengthFromQualifier(byte[] qualifier)
qualifier
- The qualifier to parseIllegalArgument
- if the qualifier is null or emptypublic static byte getValueLengthFromQualifier(byte[] qualifier, int offset)
qualifier
- The qualifier to parseoffset
- An offset within the byte arrayIllegalArgument
- if the qualifier is null or the offset falls
outside of the qualifier arraypublic static short getQualifierLength(byte[] qualifier)
qualifier
- The qualifier to parseIllegalArgument
- if the qualifier is null or emptypublic static short getQualifierLength(byte[] qualifier, int offset)
qualifier
- The qualifier to parseoffset
- An offset within the byte arrayIllegalArgument
- if the qualifier is null or the offset falls
outside of the qualifier arraypublic static long getTimestampFromQualifier(byte[] qualifier, long base_time)
qualifier
- The qualifier to parsebase_time
- The base time, in seconds, from the row keyIllegalArgument
- if the qualifier is null or emptypublic static long getTimestampFromQualifier(byte[] qualifier, long base_time, int offset)
qualifier
- The qualifier to parsebase_time
- The base time, in seconds, from the row keyoffset
- An offset within the byte arrayIllegalArgument
- if the qualifier is null or the offset falls
outside of the qualifier arraypublic static short getFlagsFromQualifier(byte[] qualifier)
qualifier
- The qualifier to parseIllegalArgument
- if the qualifier is null or emptypublic static short getFlagsFromQualifier(byte[] qualifier, int offset)
qualifier
- The qualifier to parseoffset
- An offset within the byte arrayIllegalArgument
- if the qualifier is null or the offset falls
outside of the qualifier arraypublic static byte[] extractQualifier(byte[] qualifier, int offset)
qualifier
- The qualifier to parseoffset
- An offset within the byte arrayIllegalArgument
- if the qualifier is null or the offset falls
outside of the qualifier arraypublic static byte[] buildQualifier(long timestamp, short flags)
timestamp
- A Unix epoch timestamp in seconds or millisecondsflags
- Flags to set on the qualifier (length &| float)