Class LongConverter
java.lang.Object
org.apache.hadoop.yarn.server.timelineservice.storage.common.LongConverter
- All Implemented Interfaces:
Serializable,Comparator<Number>,NumericValueConverter,ValueConverter
Encodes a value by interpreting it as a Long and converting it to bytes and
decodes a set of bytes as a Long.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds two or more numbers.intCompares two numbers as longs.decodeValue(byte[] bytes) Decode a byte array and convert it into an object depending on the converter implementation.byte[]encodeValue(Object value) Encode an object as a byte array depending on the converter implementation.static longinvertLong(long key) Converts a timestamp into it's inverse timestamp to be used in (row) keys where we want to have the most recent timestamp in the top of the table (scans start at the most recent timestamp first).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
LongConverter
public LongConverter()
-
-
Method Details
-
encodeValue
Description copied from interface:ValueConverterEncode an object as a byte array depending on the converter implementation.- Specified by:
encodeValuein interfaceValueConverter- Parameters:
value- Value to be encoded.- Returns:
- a byte array
- Throws:
IOException- if any problem is encountered while encoding.
-
decodeValue
Description copied from interface:ValueConverterDecode a byte array and convert it into an object depending on the converter implementation.- Specified by:
decodeValuein interfaceValueConverter- Parameters:
bytes- Byte array to be decoded.- Returns:
- an object
- Throws:
IOException- if any problem is encountered while decoding.
-
compare
Compares two numbers as longs. If either number is null, it will be taken as 0.- Specified by:
comparein interfaceComparator<Number>- Parameters:
num1- the firstLongto compare.num2- the secondLongto compare.- Returns:
- -1 if num1 is less than num2, 0 if num1 is equal to num2 and 1 if num1 is greater than num2.
-
add
Description copied from interface:NumericValueConverterAdds two or more numbers. If either of the numbers are null, it is taken as 0.- Specified by:
addin interfaceNumericValueConverter- Parameters:
num1- the first number to add.num2- the second number to add.numbers- Rest of the numbers to be added.- Returns:
- result after adding up the numbers.
-
invertLong
public static long invertLong(long key) Converts a timestamp into it's inverse timestamp to be used in (row) keys where we want to have the most recent timestamp in the top of the table (scans start at the most recent timestamp first).- Parameters:
key- value to be inverted so that the latest version will be first in a scan.- Returns:
- inverted long
-