Skip to content

CC-3396 - Add support for ReadRow, to query only required columns #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading