Skip to content

Commit

Permalink
Expose FamilySubset struct and a small fix
Browse files Browse the repository at this point in the history
Change-Id: Ia07847f4c43197d8498ead0e225651fe2b4713d7
  • Loading branch information
trollyxia committed Mar 14, 2024
1 parent 1644c8d commit 44d7411
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions bigtable/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2249,31 +2249,29 @@ 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
}

// 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.
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]
}
Expand All @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion bigtable/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")},
},
Expand Down

0 comments on commit 44d7411

Please sign in to comment.