Skip to content

Commit

Permalink
Refactor the code and add javadoc
Browse files Browse the repository at this point in the history
Signed-off-by: Shashwat Sharma <[email protected]>
  • Loading branch information
shshashwat committed Oct 12, 2021
1 parent ddb8939 commit 1c8021f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.google.common.base.Strings;

public class NameUtil {
private static final String DEFAULT_TYPE = "default_type";
private static final String DEFAULT_TYPE = "default_namespace";
/**
* Extracts the name from the fully qualified type name. Name represents the last token after ".".
* If the qualified name does not contain "." then the name is same as qualified name.
Expand Down Expand Up @@ -63,15 +63,17 @@ public static String qualifiedName(String qualifier, String name) {

/**
* Type value if the 'type' is not null of empty.
* If type is null or empty then the created name is simply 'namespace.groupName'.
* If type is null or empty and the namespace is null or empty created name is 'default_namespace.groupName'.
* If type is null or empty and namespace is not null or empty then created name is 'namespace.groupName'.
*
* @param type the value provided with API call (schemaInfo.getType()).
* @param groupName the name of the group for schema
* @param namespace the namespace for the schema
* @return Provided name or Created name for type in SchemaInfo
*/
public static String createTypeIfAbsent(String type, String groupName, String namespace) {
String nameSpace = Strings.isNullOrEmpty(namespace) ? DEFAULT_TYPE : namespace;
return Strings.isNullOrEmpty(type) ? String.format("%s.%s", nameSpace, groupName) : type;
Preconditions.checkNotNull(groupName, "Group can not be null");
String typeName = Strings.isNullOrEmpty(namespace) ? DEFAULT_TYPE : namespace;
return Strings.isNullOrEmpty(type) ? String.format("%s.%s", typeName, groupName) : type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,6 @@ private boolean checkCompatibility(SchemaInfo schema, GroupProperties groupPrope
}

private SchemaInfo normalizeSchemaBinary(SchemaInfo schemaInfo, String group, String namespace) {
Preconditions.checkNotNull(group, "Group can not be null");
// validates and the schema binary.
ByteBuffer schemaBinary = schemaInfo.getSchemaData();
boolean isValid = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private CompletionStage<String> addNewSchemaRecord(SchemaInfo schemaInfo, Schema
entries.put(KEY_SERIALIZER.toBytes(new SchemaIdChunkKey(id, i)),
new VersionedRecord<>(bytes, null));
}
log.info("Calling update entries for new schema addition");
log.trace("Call for update entries for new schema addition with schema {}", schemaInfo);
return tableStore.updateEntries(SCHEMAS, entries)
.thenApply(v -> id);
}
Expand Down

0 comments on commit 1c8021f

Please sign in to comment.