Fengzdadi opened a new pull request, #94:
URL: https://github.com/apache/datasketches-go/pull/94

   ## Related Issue
   
   Follow-up to #90 
   
   ## Implementation
   
   ### Files Added/Modified
   
   | File | Description |
   |------|-------------|
   | `sampling/serde.go` | SerDe interface and built-in implementations |
   | `sampling/serde_test.go` | Serialization tests |
   | `sampling/reservoir_items_sketch.go` | Added ToByteArray() and FromSlice() 
|
   
   ### SerDe Interface
   
   ```go
   type ItemsSerDe[T any] interface {
       SerializeToBytes(items []T) []byte
       DeserializeFromBytes(data []byte, numItems int) ([]T, error)
       SizeOfItem() int
   }
   ```
   
   ### Built-in SerDe
   
   | Type | SerDe | Size |
   |------|-------|------|
   | `int64` | `Int64SerDe` | 8 bytes |
   | `int32` | `Int32SerDe` | 4 bytes |
   | `float64` | `Float64SerDe` | 8 bytes |
   | `string` | `StringSerDe` | length prefix + content |
   
   ### Usage
   
   ```go
   // Serialize
   bytes, _ := sketch.ToByteArray(sampling.Int64SerDe{})
   
   // Deserialize
   restored, _ := sampling.NewReservoirItemsSketchFromSlice[int64](bytes, 
sampling.Int64SerDe{})
   ```
   
   ## Notes
   
   - Uses little-endian byte order for cross-language compatibility
   - Custom types: users implement `ItemsSerDe[T]` interface
   
   ## Testing
   
   All tests pass:
   ```
   go test ./sampling/
   ok      github.com/apache/datasketches-go/sampling
   ```


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