Skip to content

Commit

Permalink
feat(bigtable): Remove deprecated Bytes from BigEndianBytesEncoding (#…
Browse files Browse the repository at this point in the history
…10659)

* feat(bigtable): Remove deprecated Bytes from BigEndianBytesEncoding

* minor fix

* minor fix
  • Loading branch information
ron-gal authored Aug 9, 2024
1 parent b819419 commit 0bb1a6d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 53 deletions.
12 changes: 4 additions & 8 deletions bigtable/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,14 @@ type Int64Encoding interface {
}

// BigEndianBytesEncoding represents an Int64 encoding where the value is encoded
// as an 8-byte big-endian value. The byte representation may also have further encoding
// via Bytes.
// as an 8-byte big-endian value.
type BigEndianBytesEncoding struct {
Bytes BytesType
}

func (beb BigEndianBytesEncoding) proto() *btapb.Type_Int64_Encoding {
return &btapb.Type_Int64_Encoding{
Encoding: &btapb.Type_Int64_Encoding_BigEndianBytes_{
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{
BytesType: beb.Bytes.proto().GetBytesType(),
},
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{},
},
}
}
Expand Down Expand Up @@ -238,9 +234,9 @@ func int64EncodingProtoToEncoding(ie *btapb.Type_Int64_Encoding) Int64Encoding {
return unknown[btapb.Type_Int64_Encoding]{wrapped: ie}
}

switch e := ie.Encoding.(type) {
switch ie.Encoding.(type) {
case *btapb.Type_Int64_Encoding_BigEndianBytes_:
return BigEndianBytesEncoding{Bytes: bytesProtoToType(e.BigEndianBytes.BytesType)}
return BigEndianBytesEncoding{}
default:
return unknown[btapb.Type_Int64_Encoding]{wrapped: ie}
}
Expand Down
50 changes: 5 additions & 45 deletions bigtable/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ func aggregateProto() *btapb.Type {
Int64Type: &btapb.Type_Int64{
Encoding: &btapb.Type_Int64_Encoding{
Encoding: &btapb.Type_Int64_Encoding_BigEndianBytes_{
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{
BytesType: &btapb.Type_Bytes{
Encoding: &btapb.Type_Bytes_Encoding{
Encoding: &btapb.Type_Bytes_Encoding_Raw_{
Raw: &btapb.Type_Bytes_Encoding_Raw{},
},
},
},
},
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{},
},
},
},
Expand Down Expand Up @@ -79,15 +71,7 @@ func TestSumAggregateProto(t *testing.T) {
Int64Type: &btapb.Type_Int64{
Encoding: &btapb.Type_Int64_Encoding{
Encoding: &btapb.Type_Int64_Encoding_BigEndianBytes_{
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{
BytesType: &btapb.Type_Bytes{
Encoding: &btapb.Type_Bytes_Encoding{
Encoding: &btapb.Type_Bytes_Encoding_Raw_{
Raw: &btapb.Type_Bytes_Encoding_Raw{},
},
},
},
},
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{},
},
},
},
Expand Down Expand Up @@ -123,15 +107,7 @@ func TestMinAggregateProto(t *testing.T) {
Int64Type: &btapb.Type_Int64{
Encoding: &btapb.Type_Int64_Encoding{
Encoding: &btapb.Type_Int64_Encoding_BigEndianBytes_{
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{
BytesType: &btapb.Type_Bytes{
Encoding: &btapb.Type_Bytes_Encoding{
Encoding: &btapb.Type_Bytes_Encoding_Raw_{
Raw: &btapb.Type_Bytes_Encoding_Raw{},
},
},
},
},
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{},
},
},
},
Expand Down Expand Up @@ -159,15 +135,7 @@ func TestMaxAggregateProto(t *testing.T) {
Int64Type: &btapb.Type_Int64{
Encoding: &btapb.Type_Int64_Encoding{
Encoding: &btapb.Type_Int64_Encoding_BigEndianBytes_{
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{
BytesType: &btapb.Type_Bytes{
Encoding: &btapb.Type_Bytes_Encoding{
Encoding: &btapb.Type_Bytes_Encoding_Raw_{
Raw: &btapb.Type_Bytes_Encoding_Raw{},
},
},
},
},
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{},
},
},
},
Expand Down Expand Up @@ -195,15 +163,7 @@ func TestHllAggregateProto(t *testing.T) {
Int64Type: &btapb.Type_Int64{
Encoding: &btapb.Type_Int64_Encoding{
Encoding: &btapb.Type_Int64_Encoding_BigEndianBytes_{
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{
BytesType: &btapb.Type_Bytes{
Encoding: &btapb.Type_Bytes_Encoding{
Encoding: &btapb.Type_Bytes_Encoding_Raw_{
Raw: &btapb.Type_Bytes_Encoding_Raw{},
},
},
},
},
BigEndianBytes: &btapb.Type_Int64_Encoding_BigEndianBytes{},
},
},
},
Expand Down

0 comments on commit 0bb1a6d

Please sign in to comment.