laskoviymishka commented on issue #2062: URL: https://github.com/apache/iceberg-go/issues/2062#issuecomment-7188624791
Thanks @Revanth14, I reproduced both from a separate package on main. It's a bit worse than a changed value: if the schema's ID index is already built, overwriting a list type through json.Unmarshal leaves the index stale. After rewriting element 2 to element 7, String() shows the new type, `FindFieldByID(7)` returns false and `FindFieldByID(2)` still returns true. So a docs-only rule can leave a schema whose lookups disagree with its own JSON. Let's go with your proposal. The doc note is the same rule the Ref accessors relied on, and we already decided that wasn't enough. With this, the only change users see is that `NewSchema*` stops sharing the types it was given, which is what they'd expect anyway. A few details: - `NewSchema*` can skip the copy for schemas built from freshly decoded JSON, so loading metadata doesn't copy twice. A benchmark on a wide schema with many historical versions would be good to see in the PR. - For visitors, the marker from #2623 should fit: Visit walks the schema's own types when the visitor implements an unexported interface whose method takes an internal type, and a copy otherwise. Our own visitors stay zero-copy, and outside code can't opt in. - For `FieldsRef` / `FindFieldByIDRef` / `PartitionSpec.FieldsRef`, use the `init()` hooks in internal that @nssalian benchmarked earlier. This means public reads stay cloning, which drops part of the original motivation. Getting zero-copy reads would mean making the composite types values that wrap unexported pointers, which breaks every `*iceberg.ListType` type switch, so that's not for v1. @zeroshade, what's your opinion on this? -- 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]
