pub trait PrimaryKeyCodec:
Send
+ Sync
+ Debug {
// Required methods
fn encode_key_value(
&self,
key_value: &KeyValue<'_>,
buffer: &mut Vec<u8>,
) -> Result<()>;
fn encode_values(
&self,
values: &[(ColumnId, Value)],
buffer: &mut Vec<u8>,
) -> Result<()>;
fn encode_value_refs(
&self,
values: &[(ColumnId, ValueRef<'_>)],
buffer: &mut Vec<u8>,
) -> Result<()>;
fn num_fields(&self) -> Option<usize>;
fn primary_key_filter(
&self,
metadata: &RegionMetadataRef,
filters: Arc<Vec<SimpleFilterEvaluator>>,
) -> Box<dyn PrimaryKeyFilter>;
fn encoding(&self) -> PrimaryKeyEncoding;
fn decode(&self, bytes: &[u8]) -> Result<CompositeValues>;
fn decode_leftmost(&self, bytes: &[u8]) -> Result<Option<Value>>;
// Provided method
fn estimated_size(&self) -> Option<usize> { ... }
}
Required Methods§
Sourcefn encode_key_value(
&self,
key_value: &KeyValue<'_>,
buffer: &mut Vec<u8>,
) -> Result<()>
fn encode_key_value( &self, key_value: &KeyValue<'_>, buffer: &mut Vec<u8>, ) -> Result<()>
Encodes a key value to bytes.
Sourcefn encode_values(
&self,
values: &[(ColumnId, Value)],
buffer: &mut Vec<u8>,
) -> Result<()>
fn encode_values( &self, values: &[(ColumnId, Value)], buffer: &mut Vec<u8>, ) -> Result<()>
Encodes values to bytes.
Sourcefn encode_value_refs(
&self,
values: &[(ColumnId, ValueRef<'_>)],
buffer: &mut Vec<u8>,
) -> Result<()>
fn encode_value_refs( &self, values: &[(ColumnId, ValueRef<'_>)], buffer: &mut Vec<u8>, ) -> Result<()>
Encodes values to bytes.
Sourcefn num_fields(&self) -> Option<usize>
fn num_fields(&self) -> Option<usize>
Returns the number of fields in the primary key.
Sourcefn primary_key_filter(
&self,
metadata: &RegionMetadataRef,
filters: Arc<Vec<SimpleFilterEvaluator>>,
) -> Box<dyn PrimaryKeyFilter>
fn primary_key_filter( &self, metadata: &RegionMetadataRef, filters: Arc<Vec<SimpleFilterEvaluator>>, ) -> Box<dyn PrimaryKeyFilter>
Returns a primary key filter factory.
Sourcefn encoding(&self) -> PrimaryKeyEncoding
fn encoding(&self) -> PrimaryKeyEncoding
Returns the encoding type of the primary key.
Sourcefn decode(&self, bytes: &[u8]) -> Result<CompositeValues>
fn decode(&self, bytes: &[u8]) -> Result<CompositeValues>
Decodes the primary key from the given bytes.
Returns a CompositeValues
that follows the primary key ordering.
Provided Methods§
Sourcefn estimated_size(&self) -> Option<usize>
fn estimated_size(&self) -> Option<usize>
Returns the estimated size of the primary key.