Skip to content

Commit

Permalink
Update compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonHxy committed Oct 11, 2022
1 parent 24cd478 commit c2416da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ public String getSchemaDefinition() {
}
}

/**
* Calculate the SchemaHash for compatible with `@NoArgsConstructor`.
* If SchemaInfoImpl is created by no-args-constructor from users, the schemaHash will be null.
* Note: We should remove this method as long as `@NoArgsConstructor` removed at major release to avoid null-check
* overhead.
*/
public SchemaHash getSchemaHash() {
if (schemaHash == null) {
schemaHash = SchemaHash.of(this.schema, this.type);
}
return schemaHash;
}

@Override
public String toString() {
return SchemaUtils.jsonifySchemaInfo(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static SchemaHash empty() {
return EMPTY_SCHEMA_HASH;
}

// Shouldn't call this method directly
// Shouldn't call this method frequently, otherwise will bring performance regression
public static SchemaHash of(byte[] schemaBytes, SchemaType schemaType) {
return new SchemaHash(hashFunction.hashBytes(schemaBytes == null ? new byte[0] : schemaBytes), schemaType);
}
Expand Down

0 comments on commit c2416da

Please sign in to comment.