@@ -16,8 +16,9 @@ use std::num::Wrapping;
1616use crate :: { prepared_statement:: TokenCalculationError , routing:: Token } ;
1717
1818#[ allow( clippy:: upper_case_acronyms) ]
19- #[ derive( Clone , PartialEq , Debug , Default ) ]
20- pub ( crate ) enum PartitionerName {
19+ #[ derive( Clone , PartialEq , Eq , Debug , Default ) ]
20+ #[ non_exhaustive]
21+ pub enum PartitionerName {
2122 #[ default]
2223 Murmur3 ,
2324 CDC ,
@@ -75,11 +76,12 @@ impl PartitionerHasher for PartitionerHasherAny {
7576/// The Partitioners' design is based on std::hash design: `Partitioner`
7677/// corresponds to `HasherBuilder`, and `PartitionerHasher` to `Hasher`.
7778/// See their documentation for more details.
78- pub trait Partitioner {
79+ pub ( crate ) trait Partitioner {
7980 type Hasher : PartitionerHasher ;
8081
8182 fn build_hasher ( & self ) -> Self :: Hasher ;
8283
84+ #[ allow( unused) ] // Currently, no public API uses this.
8385 fn hash_one ( & self , data : & [ u8 ] ) -> Token {
8486 let mut hasher = self . build_hasher ( ) ;
8587 hasher. write ( data) ;
@@ -92,12 +94,12 @@ pub trait Partitioner {
9294/// Instances of this trait are created by a `Partitioner` and are stateful.
9395/// At any point, one can call `finish()` and a `Token` will be computed
9496/// based on values that has been fed so far.
95- pub trait PartitionerHasher {
97+ pub ( crate ) trait PartitionerHasher {
9698 fn write ( & mut self , pk_part : & [ u8 ] ) ;
9799 fn finish ( & self ) -> Token ;
98100}
99101
100- pub struct Murmur3Partitioner ;
102+ pub ( crate ) struct Murmur3Partitioner ;
101103
102104impl Partitioner for Murmur3Partitioner {
103105 type Hasher = Murmur3PartitionerHasher ;
@@ -112,7 +114,7 @@ impl Partitioner for Murmur3Partitioner {
112114 }
113115}
114116
115- pub struct Murmur3PartitionerHasher {
117+ pub ( crate ) struct Murmur3PartitionerHasher {
116118 total_len : usize ,
117119 buf : [ u8 ; Self :: BUF_CAPACITY ] ,
118120 h1 : Wrapping < i64 > ,
@@ -278,9 +280,9 @@ enum CDCPartitionerHasherState {
278280 Computed ( Token ) ,
279281}
280282
281- pub struct CDCPartitioner ;
283+ pub ( crate ) struct CDCPartitioner ;
282284
283- pub struct CDCPartitionerHasher {
285+ pub ( crate ) struct CDCPartitionerHasher {
284286 state : CDCPartitionerHasherState ,
285287}
286288
@@ -346,9 +348,9 @@ impl PartitionerHasher for CDCPartitionerHasher {
346348///
347349/// NOTE: the provided values must completely constitute partition key
348350/// and be in the order defined in CREATE TABLE statement.
349- pub fn calculate_token_for_partition_key < P : Partitioner > (
351+ pub fn calculate_token_for_partition_key (
350352 serialized_partition_key_values : & SerializedValues ,
351- partitioner : & P ,
353+ partitioner : & PartitionerName ,
352354) -> Result < Token , TokenCalculationError > {
353355 let mut partitioner_hasher = partitioner. build_hasher ( ) ;
354356
0 commit comments