Kinetica   C#   API  Version 7.2.3.1
DirectAvroEncoder< T > Class Template Reference

Ultra-high-performance Avro encoder that writes directly to binary format without using GenericRecord or the Avro library's writers. More...

Public Member Functions

byte [] Encode (T record)
 Encodes a single record to Avro binary format. More...
 
int EncodeTo (T record, ref byte[] buffer, int offset)
 Encodes a single record directly into the provided buffer. More...
 
int CalculateEncodedSize (T record)
 Calculates the encoded size of a record without actually encoding it. More...
 
byte [][] EncodeMany (IReadOnlyList< T > records)
 Encodes multiple records in parallel using thread-local buffers. More...
 
List< byte[]> EncodeManyAsList (IReadOnlyList< T > records)
 Encodes multiple records to a list. More...
 

Static Public Member Functions

static DirectAvroEncoder< T > GetOrCreate (KineticaType ktype)
 Gets or creates a DirectAvroEncoder for the specified type and KineticaType. More...
 

Public Attributes

byte [] Buffer
 Zero-copy batch encoding: encodes all records into a single contiguous buffer and returns segments pointing into that buffer. More...
 

Detailed Description

Ultra-high-performance Avro encoder that writes directly to binary format without using GenericRecord or the Avro library's writers.

This provides 2-5x faster encoding by:

  • Writing directly to a pooled byte buffer
  • Using inline varint encoding
  • Avoiding all intermediate object allocations
  • Using ArrayPool for buffer reuse

Definition at line 83 of file AvroEncoders.cs.

Member Function Documentation

◆ CalculateEncodedSize()

int DirectAvroEncoder< T >.CalculateEncodedSize ( record)
inline

Calculates the encoded size of a record without actually encoding it.

Useful for pre-allocating buffers.

Definition at line 260 of file AvroEncoders.cs.

◆ Encode()

byte [] DirectAvroEncoder< T >.Encode ( record)
inline

Encodes a single record to Avro binary format.

Uses thread-local buffer to minimize allocations.

Definition at line 218 of file AvroEncoders.cs.

◆ EncodeMany()

byte [][] DirectAvroEncoder< T >.EncodeMany ( IReadOnlyList< T >  records)
inline

Encodes multiple records in parallel using thread-local buffers.

Definition at line 272 of file AvroEncoders.cs.

◆ EncodeManyAsList()

List<byte[]> DirectAvroEncoder< T >.EncodeManyAsList ( IReadOnlyList< T >  records)
inline

Encodes multiple records to a list.

Definition at line 298 of file AvroEncoders.cs.

◆ EncodeTo()

int DirectAvroEncoder< T >.EncodeTo ( record,
ref byte []  buffer,
int  offset 
)
inline

Encodes a single record directly into the provided buffer.

Returns the number of bytes written. Buffer may be resized if needed.

Definition at line 244 of file AvroEncoders.cs.

◆ GetOrCreate()

static DirectAvroEncoder<T> DirectAvroEncoder< T >.GetOrCreate ( KineticaType  ktype)
inlinestatic

Gets or creates a DirectAvroEncoder for the specified type and KineticaType.

Definition at line 95 of file AvroEncoders.cs.

Member Data Documentation

◆ Buffer

byte [] DirectAvroEncoder< T >.Buffer

Zero-copy batch encoding: encodes all records into a single contiguous buffer and returns segments pointing into that buffer.

Zero-copy parallel batch encoding: encodes records in parallel, then concatenates into a single buffer.

Definition at line 307 of file AvroEncoders.cs.


The documentation for this class was generated from the following file: