public class StringValueArray extends Object implements ValueArray<org.apache.flink.types.StringValue>
StringValue
.
Strings are serialized to a byte array. Concatenating arrays is as simple
and fast as extending and copying byte arrays. Strings are serialized when
individually added to StringValueArray
.
For each string added to the array the length is first serialized using a variable length integer. Then the string characters are serialized using a variable length encoding where the lower 128 ASCII/UFT-8 characters are encoded in a single byte. This ensures that common characters are serialized in only two bytes.
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_CAPACITY_IN_BYTES |
protected static int |
HIGH_BIT |
Constructor and Description |
---|
StringValueArray()
Initializes an expandable array with default capacity.
|
StringValueArray(int bytes)
Initializes a fixed-size array with the provided number of bytes.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(org.apache.flink.types.StringValue value)
Appends the value to this array if and only if the array capacity would
not be exceeded.
|
boolean |
addAll(ValueArray<org.apache.flink.types.StringValue> 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<org.apache.flink.types.StringValue> o) |
ValueArray<org.apache.flink.types.StringValue> |
copy() |
void |
copy(org.apache.flink.core.memory.DataInputView source,
org.apache.flink.core.memory.DataOutputView target) |
protected static void |
copyInternal(org.apache.flink.core.memory.DataInputView source,
org.apache.flink.core.memory.DataOutputView target) |
void |
copyNormalizedKey(org.apache.flink.core.memory.MemorySegment target,
int offset,
int len) |
void |
copyTo(ValueArray<org.apache.flink.types.StringValue> target) |
boolean |
equals(Object obj) |
int |
getBinaryLength() |
int |
getMaxNormalizedKeyLen() |
int |
hashCode() |
boolean |
isFull()
An bounded array fills when the allocated capacity has been fully used.
|
Iterator<org.apache.flink.types.StringValue> |
iterator() |
void |
mark()
Saves the array index, which can be restored by calling
reset() . |
void |
read(org.apache.flink.core.memory.DataInputView in) |
void |
reset()
Restores the array index to when
mark() was last called. |
void |
setValue(ValueArray<org.apache.flink.types.StringValue> value) |
int |
size()
Returns the number of elements stored in the array.
|
String |
toString() |
void |
write(org.apache.flink.core.memory.DataOutputView out) |
protected static final int DEFAULT_CAPACITY_IN_BYTES
protected static final int HIGH_BIT
public StringValueArray()
public StringValueArray(int bytes)
bytes
- number of bytes of the encapsulated arraypublic Iterator<org.apache.flink.types.StringValue> iterator()
public void write(org.apache.flink.core.memory.DataOutputView out) throws IOException
write
in interface org.apache.flink.core.io.IOReadableWritable
IOException
public void read(org.apache.flink.core.memory.DataInputView in) throws IOException
read
in interface org.apache.flink.core.io.IOReadableWritable
IOException
public int getMaxNormalizedKeyLen()
getMaxNormalizedKeyLen
in interface org.apache.flink.types.NormalizableKey<ValueArray<org.apache.flink.types.StringValue>>
public void copyNormalizedKey(org.apache.flink.core.memory.MemorySegment target, int offset, int len)
copyNormalizedKey
in interface org.apache.flink.types.NormalizableKey<ValueArray<org.apache.flink.types.StringValue>>
public int compareTo(ValueArray<org.apache.flink.types.StringValue> o)
compareTo
in interface Comparable<ValueArray<org.apache.flink.types.StringValue>>
public int hashCode()
hashCode
in interface org.apache.flink.types.Key<ValueArray<org.apache.flink.types.StringValue>>
hashCode
in class Object
public boolean equals(Object obj)
equals
in interface org.apache.flink.types.Key<ValueArray<org.apache.flink.types.StringValue>>
equals
in class Object
public void setValue(ValueArray<org.apache.flink.types.StringValue> value)
setValue
in interface org.apache.flink.types.ResettableValue<ValueArray<org.apache.flink.types.StringValue>>
public int getBinaryLength()
getBinaryLength
in interface org.apache.flink.types.CopyableValue<ValueArray<org.apache.flink.types.StringValue>>
public void copyTo(ValueArray<org.apache.flink.types.StringValue> target)
copyTo
in interface org.apache.flink.types.CopyableValue<ValueArray<org.apache.flink.types.StringValue>>
public ValueArray<org.apache.flink.types.StringValue> copy()
copy
in interface org.apache.flink.types.CopyableValue<ValueArray<org.apache.flink.types.StringValue>>
public void copy(org.apache.flink.core.memory.DataInputView source, org.apache.flink.core.memory.DataOutputView target) throws IOException
copy
in interface org.apache.flink.types.CopyableValue<ValueArray<org.apache.flink.types.StringValue>>
IOException
protected static void copyInternal(org.apache.flink.core.memory.DataInputView source, org.apache.flink.core.memory.DataOutputView target) throws IOException
IOException
public int size()
ValueArray
size
in interface ValueArray<org.apache.flink.types.StringValue>
public boolean isFull()
ValueArray
isFull
in interface ValueArray<org.apache.flink.types.StringValue>
public boolean add(org.apache.flink.types.StringValue value)
ValueArray
add
in interface ValueArray<org.apache.flink.types.StringValue>
value
- the value to add to this arraypublic boolean addAll(ValueArray<org.apache.flink.types.StringValue> other)
ValueArray
addAll
in interface ValueArray<org.apache.flink.types.StringValue>
other
- array containing values to be added to this arraypublic void clear()
ValueArray
ValueArray.mark()
in order to allow arrays be shrunk.clear
in interface ValueArray<org.apache.flink.types.StringValue>
public void mark()
ValueArray
reset()
.
This is not serialized and is not part of the contract for
Key.equals(Object)
.mark
in interface ValueArray<org.apache.flink.types.StringValue>
public void reset()
ValueArray
mark()
was last called.reset
in interface ValueArray<org.apache.flink.types.StringValue>
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.