-
Notifications
You must be signed in to change notification settings - Fork 122
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
allowing custom float overflow handling #539
base: master
Are you sure you want to change the base?
Conversation
@@ -29,11 +29,16 @@ | |||
@RunWith(Parameterized.class) | |||
public class DecimalFloatDecodingTest | |||
{ | |||
|
|||
public static final long MAX_ALLOWED_LONG = 999_999_999_999_999_999L; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
907e5ce
to
67b0cfb
Compare
artio-codecs/src/test/java/uk/co/real_logic/artio/builder/CommonDecoderImplTest.java
Fixed
Show fixed
Hide fixed
artio-codecs/src/test/java/uk/co/real_logic/artio/builder/CommonDecoderImplTest.java
Fixed
Show fixed
Hide fixed
artio-codecs/src/test/java/uk/co/real_logic/artio/builder/CommonDecoderImplTest.java
Fixed
Show fixed
Hide fixed
2aa9924
to
544fe86
Compare
* @return instance of DecimalFloat to be use | ||
* @param <Data> generic buffer | ||
*/ | ||
<Data> DecimalFloat handleOverflow( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
@@ -94,6 +97,24 @@ public CodecConfiguration outputPath(final String outputPath) | |||
return this; | |||
} | |||
|
|||
/** | |||
* Sets the full qualified class name of a DecimalFloat overflow handler. |
There was a problem hiding this comment.
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.
544fe86
to
e807e49
Compare
e807e49
to
6183b4c
Compare
No description provided.