Class ShortValue
- java.lang.Object
-
- org.apache.flink.types.ShortValue
-
- All Implemented Interfaces:
Serializable,Comparable<ShortValue>,IOReadableWritable,CopyableValue<ShortValue>,Key<ShortValue>,NormalizableKey<ShortValue>,ResettableValue<ShortValue>,Value
@Public public class ShortValue extends Object implements NormalizableKey<ShortValue>, ResettableValue<ShortValue>, CopyableValue<ShortValue>
Boxed serializable and comparable short integer type, representing the primitive typeshort.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ShortValue()Initializes the encapsulated short with 0.ShortValue(short value)Initializes the encapsulated short with the provided value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ShortValue o)ShortValuecopy()Performs a deep copy of this object into a new instance.voidcopy(DataInputView source, DataOutputView target)Copies the next serialized instance fromsourcetotarget.voidcopyNormalizedKey(MemorySegment target, int offset, int len)Writes a normalized key for the given record into the target byte array, starting at the specified position an writing exactly the given number of bytes.voidcopyTo(ShortValue target)Performs a deep copy of this object into thetargetinstance.booleanequals(Object obj)Compares the object on equality with another object.intgetBinaryLength()Gets the length of the data type when it is serialized, in bytes.intgetMaxNormalizedKeyLen()Gets the maximal length of normalized keys that the data type would produce to determine the order of instances solely by the normalized key.shortgetValue()Returns the value of the encapsulated short.inthashCode()All keys must override the hash-code function to generate proper deterministic hash codes, based on their contents.voidread(DataInputView in)Reads the object's internal data from the given data input view.voidsetValue(short value)Sets the encapsulated short to the specified value.voidsetValue(ShortValue value)Sets the encapsulated value to another valueStringtoString()voidwrite(DataOutputView out)Writes the object's internal data to the given data output view.
-
-
-
Method Detail
-
getValue
public short getValue()
Returns the value of the encapsulated short.- Returns:
- the value of the encapsulated short.
-
setValue
public void setValue(short value)
Sets the encapsulated short to the specified value.- Parameters:
value- the new value of the encapsulated short.
-
setValue
public void setValue(ShortValue value)
Description copied from interface:ResettableValueSets the encapsulated value to another value- Specified by:
setValuein interfaceResettableValue<ShortValue>- Parameters:
value- the new value of the encapsulated value
-
read
public void read(DataInputView in) throws IOException
Description copied from interface:IOReadableWritableReads the object's internal data from the given data input view.- Specified by:
readin interfaceIOReadableWritable- Parameters:
in- the input view to read the data from- Throws:
IOException- thrown if any error occurs while reading from the input stream
-
write
public void write(DataOutputView out) throws IOException
Description copied from interface:IOReadableWritableWrites the object's internal data to the given data output view.- Specified by:
writein interfaceIOReadableWritable- Parameters:
out- the output view to receive the data.- Throws:
IOException- thrown if any error occurs while writing to the output stream
-
compareTo
public int compareTo(ShortValue o)
- Specified by:
compareToin interfaceComparable<ShortValue>
-
hashCode
public int hashCode()
Description copied from interface:KeyAll keys must override the hash-code function to generate proper deterministic hash codes, based on their contents.- Specified by:
hashCodein interfaceKey<ShortValue>- Overrides:
hashCodein classObject- Returns:
- The hash code of the key
-
equals
public boolean equals(Object obj)
Description copied from interface:KeyCompares the object on equality with another object.- Specified by:
equalsin interfaceKey<ShortValue>- Overrides:
equalsin classObject- Parameters:
obj- The other object to compare against.- Returns:
- True, iff this object is identical to the other object, false otherwise.
-
getMaxNormalizedKeyLen
public int getMaxNormalizedKeyLen()
Description copied from interface:NormalizableKeyGets the maximal length of normalized keys that the data type would produce to determine the order of instances solely by the normalized key. A value ofInteger.MAX_VALUE is interpreted as infinite.For example, 32 bit integers return four, while Strings (potentially unlimited in length) return
Integer.MAX_VALUE.- Specified by:
getMaxNormalizedKeyLenin interfaceNormalizableKey<ShortValue>- Returns:
- The maximal length of normalized keys.
-
copyNormalizedKey
public void copyNormalizedKey(MemorySegment target, int offset, int len)
Description copied from interface:NormalizableKeyWrites a normalized key for the given record into the target byte array, starting at the specified position an writing exactly the given number of bytes. Note that the comparison of the bytes is treating the bytes as unsigned bytes:int byteI = bytes[i] & 0xFF;If the meaningful part of the normalized key takes less than the given number of bytes, then it must be padded. Padding is typically required for variable length data types, such as strings. The padding uses a special character, either
0or0xff, depending on whether shorter values are sorted to the beginning or the end.- Specified by:
copyNormalizedKeyin interfaceNormalizableKey<ShortValue>- Parameters:
target- The memory segment to put the normalized key bytes into.offset- The offset in the byte array where the normalized key's bytes should start.len- The number of bytes to put.
-
getBinaryLength
public int getBinaryLength()
Description copied from interface:CopyableValueGets the length of the data type when it is serialized, in bytes.- Specified by:
getBinaryLengthin interfaceCopyableValue<ShortValue>- Returns:
- The length of the data type, or
-1, if variable length.
-
copyTo
public void copyTo(ShortValue target)
Description copied from interface:CopyableValuePerforms a deep copy of this object into thetargetinstance.- Specified by:
copyToin interfaceCopyableValue<ShortValue>- Parameters:
target- Object to copy into.
-
copy
public ShortValue copy()
Description copied from interface:CopyableValuePerforms a deep copy of this object into a new instance.This method is useful for generic user-defined functions to clone a
CopyableValuewhen storing multiple objects. With object reuse a deep copy must be created and type erasure prevents calling new.- Specified by:
copyin interfaceCopyableValue<ShortValue>- Returns:
- New object with copied fields.
-
copy
public void copy(DataInputView source, DataOutputView target) throws IOException
Description copied from interface:CopyableValueCopies the next serialized instance fromsourcetotarget.This method is equivalent to calling
IOReadableWritable.read(DataInputView)followed byIOReadableWritable.write(DataOutputView)but does not require intermediate deserialization.- Specified by:
copyin interfaceCopyableValue<ShortValue>- Parameters:
source- Data source for serialized instance.target- Data target for serialized instance.- Throws:
IOException- See Also:
IOReadableWritable
-
-