Class UnionMapWriter
- All Implemented Interfaces:
AutoCloseable
,Positionable
,BaseWriter
,BaseWriter.ListWriter
,BaseWriter.MapWriter
,BaseWriter.ScalarWriter
,BaseWriter.StructWriter
,BigIntWriter
,BitWriter
,DateDayWriter
,DateMilliWriter
,Decimal256Writer
,DecimalWriter
,DurationWriter
,FieldWriter
,FixedSizeBinaryWriter
,Float2Writer
,Float4Writer
,Float8Writer
,IntervalDayWriter
,IntervalMonthDayNanoWriter
,IntervalYearWriter
,IntWriter
,LargeVarBinaryWriter
,LargeVarCharWriter
,SmallIntWriter
,TimeMicroWriter
,TimeMilliWriter
,TimeNanoWriter
,TimeSecWriter
,TimeStampMicroTZWriter
,TimeStampMicroWriter
,TimeStampMilliTZWriter
,TimeStampMilliWriter
,TimeStampNanoTZWriter
,TimeStampNanoWriter
,TimeStampSecTZWriter
,TimeStampSecWriter
,TinyIntWriter
,UInt1Writer
,UInt2Writer
,UInt4Writer
,UInt8Writer
,VarBinaryWriter
,VarCharWriter
,ViewVarBinaryWriter
,ViewVarCharWriter
Writer for MapVectors. This extends UnionListWriter to simplify writing map entries to a list
of struct elements, with "key" and "value" fields. The procedure for writing a map begin with
startMap()
followed by startEntry()
. An entry is written by using the
key()
writer to write the key, then the value()
writer to write a value. After
writing the value, call endEntry()
to complete the entry. Each map can have 1 or more
entries. When done writing entries, call endMap()
to complete the map.
NOTE: the MapVector can have NULL values by not writing to position. If a map is started with
startMap()
, then it must have a key written. The value of a map entry can be NULL by
not using the value()
writer.
Example to write the following map to position 5 of a vector
{@code // { // 1 -> 3, // 2 -> 4, // 3 -> NULL // } UnionMapWriter writer = ... writer.setPosition(5); writer.startMap(); writer.startEntry(); writer.key().integer().writeInt(1); writer.value().integer().writeInt(3); writer.endEntry(); writer.startEntry(); writer.key().integer().writeInt(2); writer.value().integer().writeInt(4); writer.endEntry(); writer.startEntry(); writer.key().integer().writeInt(3); writer.endEntry(); writer.endMap(); </pre> </p>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.arrow.vector.complex.writer.BaseWriter
BaseWriter.ComplexWriter, BaseWriter.ListWriter, BaseWriter.MapWriter, BaseWriter.ScalarWriter, BaseWriter.StructOrListWriter, BaseWriter.StructWriter
-
Field Summary
Fields inherited from class org.apache.arrow.vector.complex.impl.UnionListWriter
vector, writer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbigInt()
bit()
void
copyReader
(FieldReader reader) void
copyReaderToField
(String name, FieldReader reader) dateDay()
decimal()
void
endEntry()
Complete the map entry.void
endMap()
Complete the map.float2()
float4()
float8()
int
integer()
boolean
This implementation returnsfalse
.key()
Return the key writer that is used to write to the "key" field.list()
map
(boolean keysSorted) void
setAddVectorAsNullable
(boolean nullable) Set flag to control the FieldType.nullable property when a writer creates a new vector.smallInt()
void
void
startMap()
Start writing a map that consists of 1 or more entries.struct()
timeNano()
timeSec()
tinyInt()
toString()
uInt1()
uInt2()
uInt4()
uInt8()
value()
Return the value writer that is used to write to the "value" field.varChar()
void
writeBigEndianBytesToDecimal
(byte[] value) void
writeBigEndianBytesToDecimal256
(byte[] value) Methods inherited from class org.apache.arrow.vector.complex.impl.UnionListWriter
allocate, bigInt, bit, clear, close, dateDay, dateMilli, decimal, decimal, decimal256, decimal256, duration, duration, duration, end, endList, fixedSizeBinary, fixedSizeBinary, fixedSizeBinary, float2, float4, float8, getField, getValueCapacity, integer, intervalDay, intervalMonthDayNano, intervalYear, largeVarBinary, largeVarChar, list, map, map, map, setPosition, setValueCount, smallInt, start, startList, struct, timeMicro, timeMilli, timeNano, timeSec, timeStampMicro, timeStampMicroTZ, timeStampMicroTZ, timeStampMicroTZ, timeStampMilli, timeStampMilliTZ, timeStampMilliTZ, timeStampMilliTZ, timeStampNano, timeStampNanoTZ, timeStampNanoTZ, timeStampNanoTZ, timeStampSec, timeStampSecTZ, timeStampSecTZ, timeStampSecTZ, tinyInt, uInt1, uInt2, uInt4, uInt8, varBinary, varChar, viewVarBinary, viewVarChar, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, writeBigEndianBytesToDecimal, writeBigEndianBytesToDecimal256, writeBigInt, writeBit, writeDateDay, writeDateMilli, writeDecimal, writeDecimal, writeDecimal, writeDecimal256, writeDecimal256, writeDecimal256, writeDuration, writeFixedSizeBinary, writeFloat2, writeFloat4, writeFloat8, writeInt, writeIntervalDay, writeIntervalMonthDayNano, writeIntervalYear, writeLargeVarBinary, writeLargeVarBinary, writeLargeVarBinary, writeLargeVarBinary, writeLargeVarBinary, writeLargeVarChar, writeLargeVarChar, writeLargeVarChar, writeNull, writeSmallInt, writeTimeMicro, writeTimeMilli, writeTimeNano, writeTimeSec, writeTimeStampMicro, writeTimeStampMicroTZ, writeTimeStampMilli, writeTimeStampMilliTZ, writeTimeStampNano, writeTimeStampNanoTZ, writeTimeStampSec, writeTimeStampSecTZ, writeTinyInt, writeUInt1, writeUInt2, writeUInt4, writeUInt8, writeVarBinary, writeVarBinary, writeVarBinary, writeVarBinary, writeVarBinary, writeVarChar, writeVarChar, writeVarChar, writeViewVarBinary, writeViewVarBinary, writeViewVarBinary, writeViewVarBinary, writeViewVarBinary, writeViewVarChar, writeViewVarChar, writeViewVarChar
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.arrow.vector.complex.Positionable
getPosition
-
Field Details
-
addVectorAsNullable
protected boolean addVectorAsNullable
-
-
Constructor Details
-
UnionMapWriter
-
-
Method Details
-
startMap
public void startMap()Start writing a map that consists of 1 or more entries.- Specified by:
startMap
in interfaceBaseWriter.MapWriter
-
endMap
public void endMap()Complete the map.- Specified by:
endMap
in interfaceBaseWriter.MapWriter
-
startEntry
public void startEntry()Start a map entry that should be followed by calls tokey()
andvalue()
writers. CallendEntry()
to complete the entry.- Specified by:
startEntry
in interfaceBaseWriter.MapWriter
-
endEntry
public void endEntry()Complete the map entry.- Specified by:
endEntry
in interfaceBaseWriter.MapWriter
-
key
Return the key writer that is used to write to the "key" field.- Specified by:
key
in interfaceBaseWriter.MapWriter
-
value
Return the value writer that is used to write to the "value" field.- Specified by:
value
in interfaceBaseWriter.MapWriter
-
tinyInt
- Specified by:
tinyInt
in interfaceBaseWriter.ListWriter
- Overrides:
tinyInt
in classUnionListWriter
-
uInt1
- Specified by:
uInt1
in interfaceBaseWriter.ListWriter
- Overrides:
uInt1
in classUnionListWriter
-
uInt2
- Specified by:
uInt2
in interfaceBaseWriter.ListWriter
- Overrides:
uInt2
in classUnionListWriter
-
smallInt
- Specified by:
smallInt
in interfaceBaseWriter.ListWriter
- Overrides:
smallInt
in classUnionListWriter
-
float2
- Specified by:
float2
in interfaceBaseWriter.ListWriter
- Overrides:
float2
in classUnionListWriter
-
integer
- Specified by:
integer
in interfaceBaseWriter.ListWriter
- Overrides:
integer
in classUnionListWriter
-
uInt4
- Specified by:
uInt4
in interfaceBaseWriter.ListWriter
- Overrides:
uInt4
in classUnionListWriter
-
float4
- Specified by:
float4
in interfaceBaseWriter.ListWriter
- Overrides:
float4
in classUnionListWriter
-
dateDay
- Specified by:
dateDay
in interfaceBaseWriter.ListWriter
- Overrides:
dateDay
in classUnionListWriter
-
intervalYear
- Specified by:
intervalYear
in interfaceBaseWriter.ListWriter
- Overrides:
intervalYear
in classUnionListWriter
-
timeSec
- Specified by:
timeSec
in interfaceBaseWriter.ListWriter
- Overrides:
timeSec
in classUnionListWriter
-
timeMilli
- Specified by:
timeMilli
in interfaceBaseWriter.ListWriter
- Overrides:
timeMilli
in classUnionListWriter
-
bigInt
- Specified by:
bigInt
in interfaceBaseWriter.ListWriter
- Overrides:
bigInt
in classUnionListWriter
-
uInt8
- Specified by:
uInt8
in interfaceBaseWriter.ListWriter
- Overrides:
uInt8
in classUnionListWriter
-
float8
- Specified by:
float8
in interfaceBaseWriter.ListWriter
- Overrides:
float8
in classUnionListWriter
-
dateMilli
- Specified by:
dateMilli
in interfaceBaseWriter.ListWriter
- Overrides:
dateMilli
in classUnionListWriter
-
timeStampSec
- Specified by:
timeStampSec
in interfaceBaseWriter.ListWriter
- Overrides:
timeStampSec
in classUnionListWriter
-
timeStampMilli
- Specified by:
timeStampMilli
in interfaceBaseWriter.ListWriter
- Overrides:
timeStampMilli
in classUnionListWriter
-
timeStampMicro
- Specified by:
timeStampMicro
in interfaceBaseWriter.ListWriter
- Overrides:
timeStampMicro
in classUnionListWriter
-
timeStampNano
- Specified by:
timeStampNano
in interfaceBaseWriter.ListWriter
- Overrides:
timeStampNano
in classUnionListWriter
-
timeMicro
- Specified by:
timeMicro
in interfaceBaseWriter.ListWriter
- Overrides:
timeMicro
in classUnionListWriter
-
timeNano
- Specified by:
timeNano
in interfaceBaseWriter.ListWriter
- Overrides:
timeNano
in classUnionListWriter
-
intervalDay
- Specified by:
intervalDay
in interfaceBaseWriter.ListWriter
- Overrides:
intervalDay
in classUnionListWriter
-
intervalMonthDayNano
- Specified by:
intervalMonthDayNano
in interfaceBaseWriter.ListWriter
- Overrides:
intervalMonthDayNano
in classUnionListWriter
-
varBinary
- Specified by:
varBinary
in interfaceBaseWriter.ListWriter
- Overrides:
varBinary
in classUnionListWriter
-
varChar
- Specified by:
varChar
in interfaceBaseWriter.ListWriter
- Overrides:
varChar
in classUnionListWriter
-
viewVarBinary
- Specified by:
viewVarBinary
in interfaceBaseWriter.ListWriter
- Overrides:
viewVarBinary
in classUnionListWriter
-
viewVarChar
- Specified by:
viewVarChar
in interfaceBaseWriter.ListWriter
- Overrides:
viewVarChar
in classUnionListWriter
-
largeVarChar
- Specified by:
largeVarChar
in interfaceBaseWriter.ListWriter
- Overrides:
largeVarChar
in classUnionListWriter
-
largeVarBinary
- Specified by:
largeVarBinary
in interfaceBaseWriter.ListWriter
- Overrides:
largeVarBinary
in classUnionListWriter
-
bit
- Specified by:
bit
in interfaceBaseWriter.ListWriter
- Overrides:
bit
in classUnionListWriter
-
decimal
- Specified by:
decimal
in interfaceBaseWriter.ListWriter
- Overrides:
decimal
in classUnionListWriter
-
decimal256
- Specified by:
decimal256
in interfaceBaseWriter.ListWriter
- Overrides:
decimal256
in classUnionListWriter
-
struct
- Specified by:
struct
in interfaceBaseWriter.ListWriter
- Overrides:
struct
in classUnionListWriter
-
list
- Specified by:
list
in interfaceBaseWriter.ListWriter
- Overrides:
list
in classUnionListWriter
-
map
- Specified by:
map
in interfaceBaseWriter.ListWriter
- Overrides:
map
in classUnionListWriter
-
setAddVectorAsNullable
public void setAddVectorAsNullable(boolean nullable) Set flag to control the FieldType.nullable property when a writer creates a new vector. If true then vectors created will be nullable, this is the default behavior. If false then vectors created will be non-nullable.- Parameters:
nullable
- Whether or not to create nullable vectors (default behavior is true)
-
writeBigEndianBytesToDecimal256
public void writeBigEndianBytesToDecimal256(byte[] value) - Specified by:
writeBigEndianBytesToDecimal256
in interfaceDecimal256Writer
- See Also:
-
writeBigEndianBytesToDecimal
public void writeBigEndianBytesToDecimal(byte[] value) - Specified by:
writeBigEndianBytesToDecimal
in interfaceDecimalWriter
- See Also:
-
isEmptyStruct
public boolean isEmptyStruct()This implementation returnsfalse
.Must be overridden by struct writers.
- Specified by:
isEmptyStruct
in interfaceBaseWriter.StructWriter
- Returns:
- whether the struct is empty
-
copyReader
- Specified by:
copyReader
in interfaceBaseWriter.ListWriter
-
copyReaderToField
- Specified by:
copyReaderToField
in interfaceBaseWriter.StructWriter
-
toString
-
getPosition
public int getPosition()- Specified by:
getPosition
in interfacePositionable
-