From 44d74119ca07cb5b054ef152d5afe622a5ecdbeb Mon Sep 17 00:00:00 2001 From: trollyxia Date: Thu, 14 Mar 2024 13:48:13 +0000 Subject: [PATCH] Expose FamilySubset struct and a small fix Change-Id: Ia07847f4c43197d8498ead0e225651fe2b4713d7 --- bigtable/admin.go | 18 ++++++++---------- bigtable/integration_test.go | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/bigtable/admin.go b/bigtable/admin.go index f42a9bcf62e3..c52d00b501f9 100644 --- a/bigtable/admin.go +++ b/bigtable/admin.go @@ -2249,7 +2249,8 @@ func (av *AuthorizedViewTypeConf) GetSubsetView() (*SubsetViewConf, error) { return av.SubsetView, nil } -type familySubset struct { +// FamilySubset represents a subset of a column family. +type FamilySubset struct { Qualifiers [][]byte QualifierPrefixes [][]byte } @@ -2257,7 +2258,7 @@ type familySubset struct { // SubsetViewConf contains configuration specific to an authorized view of subset view type. type SubsetViewConf struct { RowPrefixes [][]byte - FamilySubsets map[string]familySubset + FamilySubsets map[string]FamilySubset } // AddRowPrefix adds a new row prefix to the subset view. @@ -2265,15 +2266,12 @@ func (s *SubsetViewConf) AddRowPrefix(prefix []byte) { s.RowPrefixes = append(s.RowPrefixes, prefix) } -func (s *SubsetViewConf) getFamilySubset(familyName string) familySubset { +func (s *SubsetViewConf) getFamilySubset(familyName string) FamilySubset { if s.FamilySubsets == nil { - s.FamilySubsets = make(map[string]familySubset) + s.FamilySubsets = make(map[string]FamilySubset) } if _, ok := s.FamilySubsets[familyName]; !ok { - s.FamilySubsets[familyName] = familySubset{ - Qualifiers: [][]byte{}, - QualifierPrefixes: [][]byte{}, - } + s.FamilySubsets[familyName] = FamilySubset{} } return s.FamilySubsets[familyName] } @@ -2297,10 +2295,10 @@ func (s *SubsetViewConf) fillConf(internal *btapb.AuthorizedView_SubsetView) { s.RowPrefixes = [][]byte{} s.RowPrefixes = append(s.RowPrefixes, internal.RowPrefixes...) if s.FamilySubsets == nil { - s.FamilySubsets = make(map[string]familySubset) + s.FamilySubsets = make(map[string]FamilySubset) } for k, v := range internal.FamilySubsets { - s.FamilySubsets[k] = familySubset{ + s.FamilySubsets[k] = FamilySubset{ Qualifiers: v.Qualifiers, QualifierPrefixes: v.QualifierPrefixes, } diff --git a/bigtable/integration_test.go b/bigtable/integration_test.go index 5aae83c67ba8..6439f2e461b0 100644 --- a/bigtable/integration_test.go +++ b/bigtable/integration_test.go @@ -3660,7 +3660,7 @@ func TestIntegration_DataAuthorizedView(t *testing.T) { AuthorizedViewType: AuthorizedViewTypeSubsetView, SubsetView: &SubsetViewConf{ RowPrefixes: [][]byte{[]byte("r1")}, - FamilySubsets: map[string]familySubset{ + FamilySubsets: map[string]FamilySubset{ "fam1": { QualifierPrefixes: [][]byte{[]byte("col")}, },