zeroshade commented on code in PR #395:
URL: https://github.com/apache/arrow-go/pull/395#discussion_r2121107054
##########
parquet/variant/builder.go:
##########
@@ -848,3 +882,27 @@ func (b *Builder) Build() (Value, error) {
},
}, nil
}
+
+type variantPrimitiveType interface {
+ constraints.Integer | constraints.Float | string | []byte |
+ arrow.Date32 | arrow.Time64 | arrow.Timestamp | bool |
+ uuid.UUID | DecimalValue[decimal.Decimal32] |
+ DecimalValue[decimal.Decimal64] |
DecimalValue[decimal.Decimal128]
+}
+
+// Encode is a convenience function that produces the encoded bytes for a
primitive
+// variant value. At the moment this is just delegating to the
[Builder.Append] method,
+// but in the future it will be optimized to avoid the extra overhead and
reduce allocations.
+func Encode[T variantPrimitiveType](v T, opt ...AppendOpt) ([]byte, error) {
Review Comment:
I didn't want it to be public as I don't intend for others to use this
defined type set externally, it's just for defining the constraints on this
function (or elsewhere we use it) rather than intending it to be used
externally to this lib. This is sufficient to enable users to call this, while
restraining what types can be set, without allowing it to get referenced
directly externally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]