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 16, 2024
1 parent 1644c8d commit 0fb3604
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 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 Expand Up @@ -2401,6 +2399,7 @@ func (ac *AdminClient) AuthorizedViews(ctx context.Context, tableID string) ([]s
type UpdateAuthorizedViewConf struct {
AuthorizedViewConf AuthorizedViewConf
UpdateMask []string
IgnoreWarnings bool
}

// UpdateAuthorizedView updates an authorized view in a table according to the given configuration.
Expand All @@ -2414,6 +2413,7 @@ func (ac *AdminClient) UpdateAuthorizedView(ctx context.Context, conf UpdateAuth
req := &btapb.UpdateAuthorizedViewRequest{
AuthorizedView: av,
UpdateMask: &field_mask.FieldMask{Paths: conf.UpdateMask},
IgnoreWarnings: conf.IgnoreWarnings,
}
lro, err := ac.tClient.UpdateAuthorizedView(ctx, req)
if err != nil {
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 0fb3604

Please sign in to comment.