Skip to content

Commit

Permalink
CC-3396 - Add support for ReadRow, to query only required columns
Browse files Browse the repository at this point in the history
  • Loading branch information
ced42 committed Jan 16, 2025
1 parent 13de23b commit 0c32654
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ func (r *Repository) ReadLast(ctx context.Context, key string) (*data.Set, error
return r.read(ctx, key, bigtable.RowFilter(bigtable.LatestNFilter(1)))
}

// ReadRow reads a row from the repository while returning the cell values after
// mapping it to a data.Set. This method takes a row key as an argument, uses its internal adapter
// to read the row from Big Table, parses only the cells contained in the row to turn it into
// a map of data.Event and finally returns the data.Set that contains all the events.
func (r *Repository) ReadRow(ctx context.Context, key string, opts ...bigtable.ReadOption) (*data.Set, error) {
row, err := r.adapter.ReadRow(ctx, key, opts...)
if err != nil {
return nil, err
}
return buildEventSet([]bigtable.Row{row}, r.mapper), nil
}

func (r *Repository) read(ctx context.Context, key string, opts ...bigtable.ReadOption) (*data.Set, error) {
row, err := r.adapter.ReadRow(ctx, key, opts...)
if err != nil {
Expand Down

0 comments on commit 0c32654

Please sign in to comment.