/** * Builds a Schema.Field for the FieldPartitioner using the Schema to * determine types not fixed by the FieldPartitioner. * * @param fp a FieldPartitioner * @param schema an entity Schema that will be partitioned * @return a Schema.Field for the field partitioner, with the same name */ private static Schema.Field partitionField(FieldPartitioner<?, ?> fp, Schema schema) { return new Schema.Field( fp.getName(), partitionFieldSchema(fp, schema), null, null); }
/** * Returns a {@link Schema} for the given field name, which could be either a * schema field or a partition field. * * @param schema an entity Schema that will be partitioned * @param strategy a {@code PartitionStrategy} used to partition entities * @param name a schema or partition field name * @return a Schema for the partition or schema field */ public static Schema fieldSchema(Schema schema, PartitionStrategy strategy, String name) { if (strategy != null && Accessor.getDefault().hasPartitioner(strategy, name)) { return partitionFieldSchema(Accessor.getDefault().getPartitioner(strategy, name), schema); } Schema nested = fieldSchema(schema, name); if (nested != null) { return nested; } throw new IllegalArgumentException( "Not a schema or partition field: " + name); }