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 explicitely 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 format to a pointer, to match the
"optional" behaviour of the protobuf side.

[1] More details at:
- https://issues.apache.org/jira/browse/HBASE-7987
- apache/hbase@a669c76
  • Loading branch information
dethi committed Dec 12, 2023
1 parent 642db04 commit b125fc7
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,

Check warning on line 29 in hrpc/snapshot.go

View check run for this annotation

Codecov / codecov/patch

hrpc/snapshot.go#L29

Added line #L29 was not covered by tests
Owner: proto.String(s.owner),
}
}

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

Check warning on line 35 in hrpc/snapshot.go

View check run for this annotation

Codecov / codecov/patch

hrpc/snapshot.go#L35

Added line #L35 was not covered by tests
}

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

0 comments on commit b125fc7

Please sign in to comment.