Skip to content

Conversation

@lucianoviana
Copy link
Contributor

No description provided.

public class DecimalFloatDecodingTest
{

public static final long MAX_ALLOWED_LONG = 999_999_999_999_999_999L;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make VALUE_MAX_VAL visible instead? At least make this private.

assertFalse(decoder.validate());
}

private void assertPrice(final Object memberIDsGroupDecoder, final Object b) throws Exception
Copy link
Contributor

Choose a reason for hiding this comment

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

The first parameter name doesn't make sense, the second one could be improved too.

@@ -0,0 +1,98 @@
/*
* Copyright 2021 Adaptive Financial Consulting Ltd.
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong year.

import static uk.co.real_logic.artio.dictionary.generation.CodecGenerationWrapper.dictionaryStream;
import static uk.co.real_logic.artio.util.Reflection.get;

import org.junit.Test;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use JUnit 5 for new tests.

DecimalFloat getFloat(DecimalFloat number,
int offset,
int length,
int tagId,
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bit weird that AsciiBuffer takes a tag number.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if I dont do this then there's no way for the tagId to reach the overflow handler.

{
//noinspection unchecked
decimalFloatOverflowHandler = (Class<? extends DecimalFloatOverflowHandler>)Class.forName(
floatOverflowHandler);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to actually load that class instead of using a String fqcn?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doing this during codec generation time will fail-fast in case the class name is invalid or it's not reachable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Which means you need to have in classpath while generating code, compiling the generated code will validate that anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see - will change this then

null);
}

DecoderGenerator(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we update callers instead of adding a new constructor? It's internal, so that should be simpler.

final int dotIndex,
final int tagId)
{
return overflowHandler.handleOverflow(charReader.asString(data, offset, length),
Copy link
Contributor

Choose a reason for hiding this comment

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

This will allocate a substring, plus the API forces implementations to allocate a DecimalFloat, why not pass the existing objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point - cheers

return updateValue(number, workingScale, exponent, timesNeg, negative, value);
}

private static DecimalFloat updateValue(final DecimalFloat number, final int workingScale, final int exponent,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please format consistently, ideally every parameter on its own line if breaking is needed.

@lucianoviana lucianoviana force-pushed the luc/hy-52 branch 2 times, most recently from 2aa9924 to 544fe86 Compare January 21, 2025 15:30
* @return instance of DecimalFloat to be use
* @param <Data> generic buffer
*/
<Data> DecimalFloat handleOverflow(
Copy link
Contributor

Choose a reason for hiding this comment

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

That still forces the implementations to allocate the result, why not pass the existing instance in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope it's in a better shape now

}

/**
* Sets the full qualified class name of a DecimalFloat overflow handler.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to mention what interface it needs to implement.

@lucianoviana lucianoviana force-pushed the luc/hy-52 branch 5 times, most recently from e26b043 to 7c342c9 Compare January 27, 2025 16:57
@lucianoviana lucianoviana force-pushed the luc/hy-52 branch 3 times, most recently from 7d7e229 to 15894c1 Compare January 28, 2025 15:10
@lucianoviana lucianoviana merged commit 69cf6ce into artiofix:master Jan 28, 2025
5 of 6 checks passed
@lucianoviana lucianoviana deleted the luc/hy-52 branch January 28, 2025 16:49
lucianoviana added a commit that referenced this pull request Mar 14, 2025
* allowing custom float overflow handling

* Upgrade github actions to v4

(cherry picked from commit 69cf6ce)
writeoncereadmany pushed a commit to TransFICC/artio that referenced this pull request Oct 13, 2025
* allowing custom float overflow handling

* Upgrade github actions to v4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants