Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-4115: [PHP] Fix long encoding #3303

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

AVRO-4115: [PHP] Fix long encoding #3303

wants to merge 1 commit into from

Conversation

jonhkr
Copy link

@jonhkr jonhkr commented Jan 27, 2025

What is the purpose of the change

This PR fixes PHP long encoding on 64bit platforms as the current implementation does not support longs bigger than 1<<61.

Verifying this change

I've added new tests to cover more scenarios and uncommented existing tests.

https://issues.apache.org/jira/browse/AVRO-4115

@jonhkr
Copy link
Author

jonhkr commented Jan 27, 2025

@thiagorb @MichelHartmann can you guys take a look at this please?

@jonhkr jonhkr changed the title Fix long encoding AVRO-4115: [PHP] Fix long encoding Jan 28, 2025
@thiagorb
Copy link
Contributor

Looks good to me!

*/
class AvroVarint
{
public static function encodeLong(int $n): string
Copy link
Member

@martin-g martin-g Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it would be good to add some documentation for the new public methods in this class. The old methods (in AvroIOBinaryDecoder have at least @param, @returns, etc.
Also in the other SDKs the unit tests are associated with the class they test.
Here we don't have any tests. There are tests in DatumIOTest but it will be harder/confusing for the next contributor to make the connection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martin-g the PHP DocBlocks are a rather old-fashion thing in PHP, from the time it didn't support type-hinting. I'd suggest dropping them altogether, in favor of proper type-hinting, unless the documentation actually adds some information other than types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything is better than nothing.

namespace Apache\Avro;

/**
* Varint encoding/decoding for 64bit php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more information would be nice!
With a link to the specification and/or other resource explaining what this is about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants