mirror of
https://github.com/hanzoai/metrics.git
synced 2026-10-30 20:03:39 +00:00
Updates: - unpin AWS dependencies and run `make vendor-update` - add config options to enable checksums only if required by storage in order to preserve backwards compatibility Related issues: - https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9748 - https://github.com/VictoriaMetrics/VictoriaMetrics/issues/8622 Tested with: AWS S3, self-hosted MinIO, Linode object storage as it was failing previously with multi-part uploads (reported here - https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8630#issuecomment-2772185033). An updated library allows (PR with the fix - https://github.com/aws/aws-sdk-go-v2/pull/3151) overriding multi-part upload configurations so that compatibility can be preserved. Signed-off-by: Zakhar Bessarab <[email protected]>
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
// Copyright 2025 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package filedesc
|
|
|
|
import "google.golang.org/protobuf/reflect/protoreflect"
|
|
|
|
// UsePresenceForField reports whether the presence bitmap should be used for
|
|
// the specified field.
|
|
func UsePresenceForField(fd protoreflect.FieldDescriptor) (usePresence, canBeLazy bool) {
|
|
switch {
|
|
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
|
// Oneof fields never use the presence bitmap.
|
|
//
|
|
// Synthetic oneofs are an exception: Those are used to implement proto3
|
|
// optional fields and hence should follow non-oneof field semantics.
|
|
return false, false
|
|
|
|
case fd.IsMap():
|
|
// Map-typed fields never use the presence bitmap.
|
|
return false, false
|
|
|
|
case fd.Kind() == protoreflect.MessageKind || fd.Kind() == protoreflect.GroupKind:
|
|
// Lazy fields always use the presence bitmap (only messages can be lazy).
|
|
isLazy := fd.(interface{ IsLazy() bool }).IsLazy()
|
|
return isLazy, isLazy
|
|
|
|
default:
|
|
// If the field has presence, use the presence bitmap.
|
|
return fd.HasPresence(), false
|
|
}
|
|
}
|