public static Schema getKeySchema(Schema topicSchema) {
    Preconditions.checkArgument(topicSchema.getType() == Schema.Type.RECORD);

    Optional<Schema> newSchema = getKeySchemaFromRecord(topicSchema);
    if (newSchema.isPresent()) {
      return newSchema.get();
    } else {
      LOG.warn(String.format("No field in the schema of %s is annotated as primarykey. Using all fields for deduping",
          topicSchema.getName()));
      return topicSchema;
    }
  }
public static Schema getKeySchema ( Schema topicSchema ) { Preconditions . checkArgument ( topicSchema . getType ( ) == Schema . Type . RECORD ) ; Optional < Schema > newSchema = getKeySchemaFromRecord ( topicSchema ) ; if ( newSchema . isPresent ( ) ) { return newSchema . get ( ) ; } else { LOG . warn ( String . format ( "No field in the schema of %s is annotated as primarykey. Using all fields for deduping" , topicSchema . getName ( ) ) ) ; return topicSchema ; } }
Returns a schema composed of all fields in topicSchema whose doc match "(?i).*primarykey".
If there's no such field, topicSchema itself will be returned.