Skip to content

Commit

Permalink
hrpc/snapshot: keep version unset if not specified
Browse files Browse the repository at this point in the history
HBase has 2 snapshot formats: version 0 and version 2. Version 2
is more efficient as it doesn't require the creation of thousand of
empty files and instead create a single manifest file[1].

The snapshot format version is dependent of the SnapshotDescription.
When the version is not set, HBase will use the default version. In
HBase 1.x/2.x, the default version is 2.

Unfortunately, gohbase implementation always set the version to 0, even
when the caller didn't explicitly set the version. This is is because
internally gohbase use an int32 (not a pointer) which default to 0
implicitly.

This change switch the internal storage to a pointer, to match the
"optional" behaviour on the protobuf side.

[1] More details at:
- https://issues.apache.org/jira/browse/HBASE-7987
- apache/hbase@a669c76
  • Loading branch information
dethi authored and tsuna committed Dec 12, 2023
1 parent 642db04 commit c88d187
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hrpc/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type snap struct {
name string
table string
snapshotType *pb.SnapshotDescription_Type
version int32
version *int32
owner string
}

Expand All @@ -26,13 +26,13 @@ func (s *snap) ToProto() *pb.SnapshotDescription {
Type: s.snapshotType,
Table: proto.String(s.table),
Name: proto.String(s.name),
Version: proto.Int32(s.version),
Version: s.version,
Owner: proto.String(s.owner),
}
}

func (s *snap) Version(v int32) {
s.version = v
s.version = &v
}

func (s *snap) Owner(o string) {
Expand Down

0 comments on commit c88d187

Please sign in to comment.