public class ShortValueArray extends Object implements ValueArray<ShortValue>
ShortValue
.Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_CAPACITY_IN_BYTES |
protected static int |
ELEMENT_LENGTH_IN_BYTES |
Constructor and Description |
---|
ShortValueArray()
Initializes an expandable array with default capacity.
|
ShortValueArray(int bytes)
Initializes a fixed-size array with the provided number of shorts.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(ShortValue value)
Appends the value to this array if and only if the array capacity would not be exceeded.
|
boolean |
addAll(ValueArray<ShortValue> other)
Appends all of the values in the specified array to the end of this array.
|
void |
clear()
Resets the array to the empty state.
|
int |
compareTo(ValueArray<ShortValue> o) |
ValueArray<ShortValue> |
copy()
Performs a deep copy of this object into a new instance.
|
void |
copy(DataInputView source,
DataOutputView target)
Copies the next serialized instance from
source to target . |
protected static void |
copyInternal(DataInputView source,
DataOutputView target) |
void |
copyNormalizedKey(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.
|
void |
copyTo(ValueArray<ShortValue> target)
Performs a deep copy of this object into the
target instance. |
boolean |
equals(Object obj)
Compares the object on equality with another object.
|
int |
getBinaryLength()
Gets the length of the data type when it is serialized, in bytes.
|
int |
getMaxNormalizedKeyLen()
Gets the maximal length of normalized keys that the data type would produce to determine the
order of instances solely by the normalized key.
|
int |
hashCode()
All keys must override the hash-code function to generate proper deterministic hash codes,
based on their contents.
|
boolean |
isFull()
An bounded array fills when the allocated capacity has been fully used.
|
Iterator<ShortValue> |
iterator() |
void |
mark()
Saves the array index, which can be restored by calling
reset() . |
void |
read(DataInputView in)
Reads the object's internal data from the given data input view.
|
void |
reset()
Restores the array index to when
mark() was last called. |
void |
setValue(ValueArray<ShortValue> value)
Sets the encapsulated value to another value
|
int |
size()
Returns the number of elements stored in the array.
|
String |
toString() |
void |
write(DataOutputView out)
Writes the object's internal data to the given data output view.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected static final int ELEMENT_LENGTH_IN_BYTES
protected static final int DEFAULT_CAPACITY_IN_BYTES
public ShortValueArray()
public ShortValueArray(int bytes)
bytes
- number of bytes of the encapsulated arraypublic Iterator<ShortValue> iterator()
iterator
in interface Iterable<ShortValue>
public void write(DataOutputView out) throws IOException
IOReadableWritable
write
in interface IOReadableWritable
out
- the output view to receive the data.IOException
- thrown if any error occurs while writing to the output streampublic void read(DataInputView in) throws IOException
IOReadableWritable
read
in interface IOReadableWritable
in
- the input view to read the data fromIOException
- thrown if any error occurs while reading from the input streampublic int getMaxNormalizedKeyLen()
NormalizableKey
Integer
.MAX_VALUE is interpreted as infinite.
For example, 32 bit integers return four, while Strings (potentially unlimited in length)
return Integer
.MAX_VALUE.
getMaxNormalizedKeyLen
in interface NormalizableKey<ValueArray<ShortValue>>
public void copyNormalizedKey(MemorySegment target, int offset, int len)
NormalizableKey
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 0
or 0xff
, depending on
whether shorter values are sorted to the beginning or the end.
copyNormalizedKey
in interface NormalizableKey<ValueArray<ShortValue>>
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.public int compareTo(ValueArray<ShortValue> o)
compareTo
in interface Comparable<ValueArray<ShortValue>>
public int hashCode()
Key
hashCode
in interface Key<ValueArray<ShortValue>>
hashCode
in class Object
public boolean equals(Object obj)
Key
equals
in interface Key<ValueArray<ShortValue>>
equals
in class Object
obj
- The other object to compare against.public void setValue(ValueArray<ShortValue> value)
ResettableValue
setValue
in interface ResettableValue<ValueArray<ShortValue>>
value
- the new value of the encapsulated valuepublic int getBinaryLength()
CopyableValue
getBinaryLength
in interface CopyableValue<ValueArray<ShortValue>>
-1
, if variable length.public void copyTo(ValueArray<ShortValue> target)
CopyableValue
target
instance.copyTo
in interface CopyableValue<ValueArray<ShortValue>>
target
- Object to copy into.public ValueArray<ShortValue> copy()
CopyableValue
This method is useful for generic user-defined functions to clone a CopyableValue
when storing multiple objects. With object reuse a deep copy must be created and type erasure
prevents calling new.
copy
in interface CopyableValue<ValueArray<ShortValue>>
public void copy(DataInputView source, DataOutputView target) throws IOException
CopyableValue
source
to target
.
This method is equivalent to calling IOReadableWritable.read(DataInputView)
followed by IOReadableWritable.write(DataOutputView)
but does not require
intermediate deserialization.
copy
in interface CopyableValue<ValueArray<ShortValue>>
source
- Data source for serialized instance.target
- Data target for serialized instance.IOException
IOReadableWritable
protected static void copyInternal(DataInputView source, DataOutputView target) throws IOException
IOException
public int size()
ValueArray
size
in interface ValueArray<ShortValue>
public boolean isFull()
ValueArray
isFull
in interface ValueArray<ShortValue>
public boolean add(ShortValue value)
ValueArray
add
in interface ValueArray<ShortValue>
value
- the value to add to this arraypublic boolean addAll(ValueArray<ShortValue> other)
ValueArray
addAll
in interface ValueArray<ShortValue>
other
- array containing values to be added to this arraypublic void clear()
ValueArray
This may reset the ValueArray.mark()
in order to allow arrays be shrunk.
clear
in interface ValueArray<ShortValue>
public void mark()
ValueArray
reset()
.
This is not serialized and is not part of the contract for Key.equals(Object)
.
mark
in interface ValueArray<ShortValue>
public void reset()
ValueArray
mark()
was last called.reset
in interface ValueArray<ShortValue>
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.