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

Ojdbc provider jackson oson #118

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

fmeheust
Copy link
Member

No description provided.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 12, 2024
Copy link
Member

@jjspiegel jjspiegel left a comment

Choose a reason for hiding this comment

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

Looks fantastic, thank you for doing this. Most of my comments are trivial, please see the one about UUID serialization though.

@Override
public void writeUTF8String(byte[] buffer, int offset, int len) throws IOException {
_verifyValueWrite("writeUTF8String");
gen.write(new String(buffer, offset, len, StandardCharsets.UTF_8));
Copy link
Member

Choose a reason for hiding this comment

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

OsonParserImpl and OsonGeneratorImpl have the ability to do UTF8 passthrough. See:
https://codesearch.oraclecorp.com/cs/xref/RDBMS_MAIN_LINUX.X64/dbjava/src/java/oracle/jdbc/driver/json/binary/OsonGeneratorImpl.java#2175

It would be great if we expose these methods and use them here to avoid string construction.

Copy link
Member Author

Choose a reason for hiding this comment

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

These will have to be done on another version, since it would require changes to the driver

@@ -0,0 +1,57 @@
# OSON Provider for Jackson
Copy link
Member

Choose a reason for hiding this comment

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

Nice README. It would be great if you could include a definition of the type mappings, i.e. a table with one column that lists Java types and the default OSON mapping.

Also if I want to override a mapping for some field and gain access to the underlying OracleJsonParser and OracleJsonGenerator is this possible?

protected void _verifyValueWrite(String typeMsg) throws IOException {
int status = _writeContext.writeValue();
if(status == _writeContext.STATUS_EXPECT_NAME) {
_reportError("error: expecting value. Got name: " + typeMsg);
Copy link
Member

Choose a reason for hiding this comment

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

Should these strings be externalized for translation?

Copy link
Member Author

Choose a reason for hiding this comment

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

For now error messages are not translated in the extensions.

* of the JSON object.
* </p>
*/
public class AccessJsonColumnUsingJacksonObjectNode {
Copy link
Member

Choose a reason for hiding this comment

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

I think that this example should point out that this is only recommended if some existing API requires to consume the data as ObjectNode. Otherwise, it would be better to use OracleJsonObject as this will provide in-place reads of the underlying data without making a copy and it will better expose the underlying type system.

public static void main(String[] args) {
try {
// set the system property to the class implementing the "oracle.jdbc.spi.JsonProvider interface"
System.setProperty(OracleConnection.CONNECTION_PROPERTY_PROVIDER_JSON, JacksonOsonProvider.PROVIDER_NAME);
Copy link
Member

Choose a reason for hiding this comment

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

Does this have to be done by system property?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it can also be added as connection property, I have changed the samples.

Copy link
Member

@MouhsinElmajdouby MouhsinElmajdouby left a comment

Choose a reason for hiding this comment

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

This is really great work, Please take a look at my review comments. Some of them, such as those related to indentation (2), line length (80-character limit), and copyright formatting, might apply to multiple places across the files.

@loiclefevre
Copy link
Member

Can't wait for this to be merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants