Skip to content

Instantly share code, notes, and snippets.

@rdblue
Created April 2, 2015 23:31
Show Gist options
  • Save rdblue/4f36915e2bc9a0261c65 to your computer and use it in GitHub Desktop.
Save rdblue/4f36915e2bc9a0261c65 to your computer and use it in GitHub Desktop.
Column projection methods
/**
* Creates a copy of this {@code View} for entities of the given type class.
*
* @param type a Java Class to use for entities
* @return a copy of this view for the given type
* @throws org.kitesdk.data.IncompatibleSchemaException
* If the schema for {@code type} is incompatible with the
* underlying dataset's Schema.
*/
<T> RefinableView<T> asType(Class<T> type);
/**
* Creates a copy of this {@code View} for the given {@link Schema}.
* <p>
* This method always returns a {@code View} for {@code GenericRecord}. To
* use specific, reflect, or other records, use {@link #asType(Class)}.
*
* @param schema an Avro Schema to use for entities
* @return a copy of this view for the given Schema
* @throws org.kitesdk.data.IncompatibleSchemaException
* If the {@code schema} is incompatible with the underlying
* dataset's Schema.
*/
<T extends GenericRecord> RefinableView<T> asSchema(Schema schema);
/**
* Creates a copy of this {@code View} with a {@link Schema} created from
* only the given {@code fields}.
* <p>
* Each field must be present in the underlying dataset's Schema. The
* returned view's Schema is constructed by adding each selected field to a
* new Schema that is a filtered version of the initial Schema.
*
* @param fields a list of selected Avro Schema fields
* @return a copy of this view for the given Schema
* @throws java.lang.IllegalArgumentException
* If one of the selected {@code fields} is not present in the
* underlying dataset's Schema.
*/
<T extends GenericRecord> RefinableView<T> select(String... fields);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment