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

   Closes #2124.
   
   ## Problem
   
   `rest.Catalog.LoadTable` always downloads and parses the full metadata JSON, 
even when the table has not changed. The REST spec lets `loadTable` send 
`If-None-Match` with the `ETag` from a previous `LoadTableResponse`, and lets 
the server answer `304 Not Modified`. Iceberg Java's `RESTTableCache` already 
does this.
   
   ## Fix
   
   - **Cache:** a bounded, per-catalog cache maps each table identifier to its 
ETag and parsed load response. It is configured by Java's property names and 
defaults: `rest-table-cache.max-entries` (100; `0` disables) and 
`rest-table-cache.expire-after-write-ms` (5 minutes). Reads do not extend an 
entry's lifetime. Invalid values fail `NewCatalog`.
   - **LoadTable:** on a cache hit, `LoadTable` sends `If-None-Match`. On a 
`304` it builds a new table from the cached response. A `200` with an `ETag` 
updates the cache. A `304` to a request that sent no ETag is still an error.
   - **Invalidation (same points as Java):** a 404 on load, `DropTable`, 
`PurgeTable`, the rename source, `CheckTableExists` returning false, and 
`Close`.
   
   
   ## Testing
   
   `table_cache_test.go` tests against an `httptest` server:
   - a 304 reuses the cached response and returns a distinct table;
   - a changed ETag replaces the entry;
   - a response without an `ETag` is not cached;
   - `max-entries=0` disables the cache;
   - an unrequested 304 is rejected;
   - each invalidation path clears the entry;
   - invalid properties are rejected.
   
   `table_cache_internal_test.go` checks expire-after-write with a fake clock, 
the entry limit, and key uniqueness.
   
   Each test was confirmed to fail when the code it covers is removed. `go test 
-race ./...` and `go vet ./...` pass.
   
   ## Context
   
   Java reference: `RESTTableCache`, plus `RESTSessionCatalog.loadTable` and 
its invalidation call sites, with tests in `TestFreshnessAwareLoading`. 
Lakekeeper sends `ETag` and answers `304` from v0.11.0.


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