Skip to content

[DE-959] Improve serde perfs #588

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

Merged
merged 20 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improved deserialize bytes at json pointer
  • Loading branch information
rashtao committed Dec 10, 2024
commit 24376b6f2548744a33cb5568d157ce6474edec64
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ default <T> T deserialize(byte[] content, String jsonPointer, Class<T> clazz) {
* @param type target data type
* @return deserialized object
*/
// TODO: avoid serialization-deserialization round-trip
default <T> T deserialize(byte[] content, String jsonPointer, Type type) {
return deserialize(parse(content, jsonPointer), type);
return deserialize(extract(content, jsonPointer), type);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static byte[] extractBytes(JsonParser parser) throws IOException {
}
byte[] data = (byte[]) parser.currentTokenLocation().contentReference().getRawContent();
int start = (int) parser.currentTokenLocation().getByteOffset();
int end = (int) parser.currentLocation().getByteOffset();
if (t.isStructStart()) {
int open = 1;
while (open > 0) {
Expand All @@ -117,7 +118,9 @@ public static byte[] extractBytes(JsonParser parser) throws IOException {
}
}
parser.finishToken();
int end = (int) parser.currentLocation().getByteOffset();
if ("JSON".equals(parser.getCodec().getFactory().getFormatName())) {
end = (int) parser.currentLocation().getByteOffset();
}
return Arrays.copyOfRange(data, start, end);
}

Expand Down