-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fix #1417: optimize/improve codec lookup handling #1443
Conversation
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.
LGTM
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.
nit picks and some things
} | ||
} | ||
|
||
public static JSONCodecRegistry create(List<JSONCodec<?, ?>> codecs) { |
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 static factory seems unnecessary, it has one line that calls the constructor
this.codecs = Objects.requireNonNull(codecs, "codecs must not be null"); | ||
private JSONCodecRegistry(List<JSONCodec<?, ?>> codecs) { | ||
Objects.requireNonNull(codecs, "codecs must not be null"); | ||
this.codecsByCQLType = new HashMap<>(); |
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.
nit: unnecessary use of this
if (match == null) { | ||
// Different exception for this case: CQL type supported but not from given Java type | ||
// (f.ex, CQL Boolean from Java/JSON number) | ||
throw new ToCQLCodecException( |
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 is an important change, the code to verify a document for inserting may need to change
@@ -49,21 +61,35 @@ public class JSONCodecRegistry { | |||
*/ | |||
public <JavaT, CqlT> JSONCodec<JavaT, CqlT> codecToCQL( | |||
TableMetadata table, CqlIdentifier column, Object value) | |||
throws UnknownColumnException, MissingJSONCodecException { | |||
throws UnknownColumnException, MissingJSONCodecException, ToCQLCodecException { |
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.
Nit: the doc comments list all the errors
What this PR does:
Changes linear-scan lookup into map-based lookup (one- or two-phase depending on direction). Also improves error messages for partial misses where we support CQL type but not particular coercion (like Boolean from Integer) to indicate it's Java value mismatch and not (fully) unsupported type.
Which issue(s) this PR fixes:
Fixes #1417
Checklist