Java SDK Documentation  24.2.0
com.vertica.sdk.vmap.v1.Encoder Class Reference
Inheritance diagram for com.vertica.sdk.vmap.v1.Encoder:
Inheritance graph
Collaboration diagram for com.vertica.sdk.vmap.v1.Encoder:
Collaboration graph

Classes

class  MatchingKeySelector
 

Public Member Functions

 Encoder (TypeCoercion coercion)
 
int byteSize ()
 
void consume (Map< String, ?> data)
 
void consume (Iterator< Map.Entry< String, Object >> data)
 
void consume (Iterator< Map.Entry< String, Object >> data, int sizeEstimate)
 
ByteBuffer encode ()
 
void encode (ByteBuffer buffer)
 
String keyForIdent (String ident)
 

Detailed Description

An encoder able to generate a VMap, Vertica's aggregate data type.

To use, call consume followed by encode().

Constructor & Destructor Documentation

◆ Encoder()

com.vertica.sdk.vmap.v1.Encoder.Encoder ( TypeCoercion  coercion)

Create an Encoder instance.

Parameters
coercionA TypeCoercion instance used to provide guidance on serializing input data before encoding it into a VMap.

Member Function Documentation

◆ byteSize()

int com.vertica.sdk.vmap.v1.Encoder.byteSize ( )

Returns the output length of the encoded VMap. Available only after consume.

Returns
The byte size of the output vmap.

Referenced by com.vertica.sdk.vmap.v1.Encoder.encode().

◆ consume() [1/3]

void com.vertica.sdk.vmap.v1.Encoder.consume ( Map< String, ?>  data)

Execute the consume phase of encoding.

Parameters
dataA map of data specified with String keys.

Referenced by com.vertica.sdk.vmap.v1.Encoder.consume(), com.vertica.sdk.PartitionWriter.setRowFromMap(), and com.vertica.sdk.PartitionWriter.setVMap().

◆ consume() [2/3]

void com.vertica.sdk.vmap.v1.Encoder.consume ( Iterator< Map.Entry< String, Object >>  data)

Execute the consume phase of encoding with a default guess at the number of data elements.

Parameters
dataAn iterator over a map-like object which has all String keys.

◆ consume() [3/3]

void com.vertica.sdk.vmap.v1.Encoder.consume ( Iterator< Map.Entry< String, Object >>  data,
int  sizeEstimate 
)

Execute the consume phase of encoding.

Parameters
dataAn iterator over a map-like object which has all String keys.
sizeEstimateA guess at the number of elements found in data. Iterators do not provide a means of querying size.

◆ encode() [1/2]

ByteBuffer com.vertica.sdk.vmap.v1.Encoder.encode ( )

Get the encoded VMap as a new ByteBuffer.

Returns
A ByteBuffer with the VMap representation from 0 to limit.

◆ encode() [2/2]

void com.vertica.sdk.vmap.v1.Encoder.encode ( ByteBuffer  buffer)

Write the VMap into a ByteBuffer and return the number of bytes written. The buffer's position will be advanced to the end of the VMap.

Parameters
bufferThe target buffer, which must have at least byteSize() remaining, or a BufferOverflowException will result.

◆ keyForIdent()

String com.vertica.sdk.vmap.v1.Encoder.keyForIdent ( String  ident)

Returns the key name of the first key that matches ident according to identifier comparison. Requires that data already be consumed.

See also
#consume(Map)

Implements com.vertica.sdk.vmap.v1.KeySelector.