}
// Ensure schema is limited to keySchema's fields. The class may have more
// fields
// in the case that the entity is being used as a key.
List<Field> fields = Lists.newArrayList();
PartitionStrategy strategy = keySchema.getPartitionStrategy();
for (Schema.Field field : keySchema.getAvroSchema().getFields()) {
String sourceName = strategy.getPartitioner(field.name()).getSourceName();
fields.add(copy(schemaField.getField(sourceName)));
}
Schema schema = Schema.createRecord(keySchema.getAvroSchema().getName(),
keySchema.getAvroSchema().getDoc(), keySchema.getAvroSchema()
.getNamespace(), keySchema.getAvroSchema().isError());