proost commented on code in PR #108:
URL: https://github.com/apache/datasketches-go/pull/108#discussion_r2723790034


##########
sampling/varopt_items_sketch.go:
##########
@@ -524,3 +529,256 @@ func (s *VarOptItemsSketch[T]) adjustedSize(maxSize, 
resizeTarget int) int {
        }
        return maxSize
 }
+
+// VarOptItemsSketchEncoder writes a Java-compatible VarOpt sketch to an 
io.Writer.
+type VarOptItemsSketchEncoder[T any] struct {
+       w     io.Writer
+       serde ItemsSerDe[T]
+}
+
+// NewVarOptItemsSketchEncoder creates an encoder with the provided writer and 
serde.
+func NewVarOptItemsSketchEncoder[T any](w io.Writer, serde ItemsSerDe[T]) 
*VarOptItemsSketchEncoder[T] {

Review Comment:
   Can you return value not pointer? returning pointer can be allocated in 
heap. Encoder is used once to encoding. I don't think it has long life cycle. 
So avoiding allocated in heap is good. 
   
   ``` 
   sampling/varopt_items_sketch.go:541:9: 
&VarOptItemsSketchEncoder[go.shape.string]{...} escapes to heap in 
NewVarOptItemsSketchEncoder[go.shape.string]:
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to