@@ -401,17 +401,26 @@ func WithRebalanceCallback(cb RebalanceCallback) ProcessorOption {
401401// view options
402402///////////////////////////////////////////////////////////////////////////////
403403
404+ type viewPartitionerCompat int
405+
406+ const (
407+ // Interpret the bytes of the key digest as an unsigned integer to match
408+ // librdkafka's partitioning behavior.
409+ librdkafkaCompat viewPartitionerCompat = iota + 1
410+ )
411+
404412// ViewOption defines a configuration option to be used when creating a view.
405413type ViewOption func (* voptions , Table , Codec )
406414
407415type voptions struct {
408- log logger
409- clientID string
410- tableCodec Codec
411- updateCallback UpdateCallback
412- hasher func () hash.Hash32
413- autoreconnect bool
414- backoffResetTime time.Duration
416+ log logger
417+ clientID string
418+ tableCodec Codec
419+ updateCallback UpdateCallback
420+ hasher func () hash.Hash32
421+ partitionerCompat viewPartitionerCompat
422+ autoreconnect bool
423+ backoffResetTime time.Duration
415424
416425 builders struct {
417426 storage storage.Builder
@@ -476,6 +485,15 @@ func WithViewHasher(hasher func() hash.Hash32) ViewOption {
476485 }
477486}
478487
488+ // WithViewHashUnsigned instructs the partitioner to interpret the key digest
489+ // as an unsigned integer when partitioning. Combine this option with the
490+ // CRC-32 hash algorithm for compatibility with librdkafka.
491+ func WithViewHashUnsigned () ViewOption {
492+ return func (o * voptions , table Table , codec Codec ) {
493+ o .partitionerCompat = librdkafkaCompat
494+ }
495+ }
496+
479497// WithViewClientID defines the client ID used to identify with Kafka.
480498func WithViewClientID (clientID string ) ViewOption {
481499 return func (o * voptions , table Table , codec Codec ) {
0 commit comments