From b125fc74df3703fac8a2e1efb0085a7e5455c5ab Mon Sep 17 00:00:00 2001 From: Thibault Deutsch Date: Tue, 12 Dec 2023 12:46:49 +0000 Subject: [PATCH] hrpc/snapshot: keep version unset if not specified 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 - https://github.com/apache/hbase/commit/a669c765f7de5b8445229c8ff9274051df7b794c --- hrpc/snapshot.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hrpc/snapshot.go b/hrpc/snapshot.go index fad96b25..0f40305a 100644 --- a/hrpc/snapshot.go +++ b/hrpc/snapshot.go @@ -17,7 +17,7 @@ type snap struct { name string table string snapshotType *pb.SnapshotDescription_Type - version int32 + version *int32 owner string } @@ -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) {