harshilv17 opened a new pull request, #2735:
URL: https://github.com/apache/iceberg-go/pull/2735

   ## What
   
   `Table.ComputeNDVs` now writes each value's Iceberg single-value 
serialization straight from the Arrow array into the Theta sketch update 
(`ndvValueBytes` in `table/stats_ndv.go`). Covered: boolean, int, long, float, 
double, date, time (us), timestamp/timestamptz/timestamp_ns/timestamptz_ns (any 
Arrow unit, same conversion as today), decimal128, string/large_string, 
binary/large_binary, fixed and uuid. Strings take the fast path only under 
string columns, since the literal path converts them for binary, fixed and uuid 
columns. Everything else, and any value that fails to convert, falls back to 
the existing literal path, which still reports the error.
   
   Strings, binary, fixed and uuid pass the Arrow bytes through with no copy. 
Decimals are encoded as minimal-length big-endian two's complement from the 
128-bit value, without `big.Int`.
   
   ## Why
   
   The old path built an `iceberg.Literal` and called `MarshalBinary` for every 
non-null value: an interface conversion and 2 to 5 allocations per value, on 
every row of every analyzed column. Fixes #2616.
   
   ## Testing
   
   - `TestNDVValueBytesMatchesLiteral` checks that the fast path returns the 
same bytes as `getArrowValueAsIcebergLiteral` + `MarshalBinary` for each 
covered type, with edge values (negative and min/max ints, `-0.0`, decimals at 
the sign-byte boundaries and int128 min/max, timestamp unit conversions in both 
directions, empty and non-ASCII strings), on whole and sliced arrays. It also 
fails if a covered type quietly falls back.
   - `TestNDVValueBytesStringFallsBackForConvertedTypes` checks that strings 
under uuid, binary and fixed columns take the literal path.
   - The existing `TestComputeNDVsTypes` and 
`TestComputeNDVsMatchesJavaFixtures` pass unchanged, so the sketches are the 
same.
   - Breaking the encoding makes the tests fail: changing the decimal sign trim 
fails the decimal case, switching int32 to big-endian fails the int and date 
cases, and dropping the string column check fails the fallback test.
   - `BenchmarkAddRecordToSketches`, 8192 rows per column, Apple M-series, 
`-count=5` means:
   
   | column    | before ns/op | after ns/op | before allocs/op | after 
allocs/op |
   
|-----------|-------------:|------------:|-----------------:|----------------:|
   | long      | 440,500 | 238,500 | 24,073 | 9 |
   | string    | 569,700 | 249,800 | 24,585 | 9 |
   | decimal   | 799,300 | 276,300 | 40,969 | 9 |
   | timestamp | 477,100 | 255,100 | 24,585 | 9 |
   
   The 9 allocations left are from creating the sketch and the targets map on 
each iteration.
   
   - `go test ./table/... -count=1` and `golangci-lint run ./table/...` both 
pass.
   


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