shivendra-dev54 opened a new pull request, #878: URL: https://github.com/apache/incubator-graphar/pull/878
<!-- Thanks for contributing to GraphAr. If this is your first pull request you can find detailed information on [CONTRIBUTING.md](https://github.com/apache/graphar/blob/main/CONTRIBUTING.md) The Apache GraphAr (incubating) community has restrictions on the naming of pr title. You can find instructions in [CONTRIBUTING.md](https://github.com/apache/graphar/blob/main/CONTRIBUTING.md#title) too. --> ### Reason for this PR Fixes #865. The standard int type is platform-dependent, and using -1 as a "not found" sentinel value leads to dangerous integer underflow bugs when comparing or casting against unsigned types like size_t (e.g., returning 18446744073709551615). This PR modernizes the GraphInfo APIs to use platform-independent types and safer missing-value handling. ### What changes are included in this PR? - Replaced int with size_t for all container indices and sizes inside VertexInfo, EdgeInfo, and GraphInfo implementations. - Updated LookupKeyIndex and associated index getter methods (like GetVertexInfoIndex) to return std::optional<size_t> instead of relying on -1. - Removed unsafe static_cast<size_t>(-1) logic from search loops (e.g., inside RemovePropertyGroup and RemoveAdjacentList). ### Are these changes tested? Yes, these changes are fully covered by the existing test suite: - Compiled successfully locally (make -j). - Passed local C++ test suite via ctest with GAR_TEST_DATA set (100% tests passed). - Code formatted using the devcontainer's clang-format. ### Are there any user-facing changes? Yes, for developers directly consuming the C++ APIs. <!-- If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking. --> **BREAKING CHANGE: C++ API Return Types** Methods that previously returned an integer index, such as GraphInfo::GetVertexInfoIndex and GraphInfo::GetEdgeInfoIndex, now safely return a std::optional<size_t>. Callers will need to check .has_value() instead of comparing against -1. <!-- Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious. --> <!-- **Critical Fix: <description>** --> -- 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]
