org.kitesdk.data
Class DatasetDescriptor.Builder

java.lang.Object
  extended by org.kitesdk.data.DatasetDescriptor.Builder
Enclosing class:
DatasetDescriptor

public static class DatasetDescriptor.Builder
extends Object

A fluent builder to aid in the construction of DatasetDescriptors.


Constructor Summary
DatasetDescriptor.Builder()
           
DatasetDescriptor.Builder(DatasetDescriptor descriptor)
          Creates a Builder configured to copy descriptor, if it is not modified.
 
Method Summary
 DatasetDescriptor build()
          Build an instance of the configured dataset descriptor.
 DatasetDescriptor.Builder format(Format format)
          Configure the dataset's format (optional).
 DatasetDescriptor.Builder format(String formatName)
          Configure the dataset's format from a format name String (optional).
 DatasetDescriptor.Builder location(Path uri)
          Configure the Dataset's location (optional).
 DatasetDescriptor.Builder location(String uri)
          Configure the Dataset's location (optional).
 DatasetDescriptor.Builder location(URI uri)
          Configure the Dataset's location (optional).
 DatasetDescriptor.Builder partitionStrategy(PartitionStrategy partitionStrategy)
          Configure the dataset's partitioning strategy (optional).
 DatasetDescriptor.Builder property(String name, String value)
          Add a key-value property to the descriptor.
<T> DatasetDescriptor.Builder
schema(Class<T> type)
          Configure the dataset's schema via a Java class type.
 DatasetDescriptor.Builder schema(File file)
          Configure the dataset's schema from a File.
 DatasetDescriptor.Builder schema(InputStream in)
          Configure the dataset's schema from an InputStream.
 DatasetDescriptor.Builder schema(Schema schema)
          Configure the dataset's schema.
 DatasetDescriptor.Builder schemaFromAvroDataFile(File file)
          Configure the dataset's schema by using the schema from an existing Avro data file.
 DatasetDescriptor.Builder schemaFromAvroDataFile(InputStream in)
          Configure the dataset's schema by using the schema from an existing Avro data file.
 DatasetDescriptor.Builder schemaFromAvroDataFile(URI uri)
          Configure the dataset's schema by using the schema from an existing Avro data file.
 DatasetDescriptor.Builder schemaLiteral(String s)
          Configure the dataset's schema from a String.
 DatasetDescriptor.Builder schemaUri(String uri)
          Configure the Dataset's schema from a String URI.
 DatasetDescriptor.Builder schemaUri(URI uri)
          Configure the Dataset's schema from a URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatasetDescriptor.Builder

public DatasetDescriptor.Builder()

DatasetDescriptor.Builder

public DatasetDescriptor.Builder(DatasetDescriptor descriptor)
Creates a Builder configured to copy descriptor, if it is not modified. This is intended to help callers copy and update descriptors even though they are Immutable.

Parameters:
descriptor - A DatasetDescriptor to copy settings from
Since:
0.7.0
Method Detail

schema

public DatasetDescriptor.Builder schema(Schema schema)
Configure the dataset's schema. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Returns:
An instance of the builder for method chaining.

schema

public DatasetDescriptor.Builder schema(File file)
                                 throws IOException
Configure the dataset's schema from a File. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Returns:
An instance of the builder for method chaining.
Throws:
IOException

schema

public DatasetDescriptor.Builder schema(InputStream in)
                                 throws IOException
Configure the dataset's schema from an InputStream. It is the caller's responsibility to close the InputStream. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Returns:
An instance of the builder for method chaining.
Throws:
IOException

schemaUri

public DatasetDescriptor.Builder schemaUri(URI uri)
                                    throws IOException
Configure the Dataset's schema from a URI. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Parameters:
uri - a URI object for the schema's location.
Returns:
An instance of the builder for method chaining.
Throws:
MalformedURLException - if uri is not a valid URL
IOException
Since:
0.8.0

schemaUri

public DatasetDescriptor.Builder schemaUri(String uri)
                                    throws URISyntaxException,
                                           IOException
Configure the Dataset's schema from a String URI. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Parameters:
uri - a String URI
Returns:
An instance of the builder for method chaining.
Throws:
URISyntaxException - if uri is not a valid URI
MalformedURLException - if uri is not a valid URL
IOException
Since:
0.8.0

schemaLiteral

public DatasetDescriptor.Builder schemaLiteral(String s)
Configure the dataset's schema from a String. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Returns:
An instance of the builder for method chaining.
Since:
0.8.0

schema

public <T> DatasetDescriptor.Builder schema(Class<T> type)
Configure the dataset's schema via a Java class type. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Returns:
An instance of the builder for method chaining.
Since:
0.2.0

schemaFromAvroDataFile

public DatasetDescriptor.Builder schemaFromAvroDataFile(File file)
                                                 throws IOException
Configure the dataset's schema by using the schema from an existing Avro data file. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Returns:
An instance of the builder for method chaining.
Throws:
IOException

schemaFromAvroDataFile

public DatasetDescriptor.Builder schemaFromAvroDataFile(InputStream in)
                                                 throws IOException
Configure the dataset's schema by using the schema from an existing Avro data file. It is the caller's responsibility to close the InputStream. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Returns:
An instance of the builder for method chaining.
Throws:
IOException

schemaFromAvroDataFile

public DatasetDescriptor.Builder schemaFromAvroDataFile(URI uri)
                                                 throws IOException
Configure the dataset's schema by using the schema from an existing Avro data file. A schema is required, and may be set using one of the methods: schema, schemaLiteral, schemaUri, or schemaFromAvroDataFile.

Returns:
An instance of the builder for method chaining.
Throws:
IOException

format

public DatasetDescriptor.Builder format(Format format)
Configure the dataset's format (optional). If not specified Formats.AVRO is used by default.

Returns:
An instance of the builder for method chaining.
Since:
0.2.0

format

public DatasetDescriptor.Builder format(String formatName)
Configure the dataset's format from a format name String (optional). If not specified, Formats.AVRO will be used.

Parameters:
formatName - a String format name
Returns:
An instance of the builder for method chaining.
Throws:
UnknownFormatException - if the format name is not recognized.
Since:
0.8.0

location

public DatasetDescriptor.Builder location(URI uri)
Configure the Dataset's location (optional).

Parameters:
uri - A URI location
Returns:
An instance of the builder for method chaining.
Since:
0.8.0

location

public DatasetDescriptor.Builder location(Path uri)
Configure the Dataset's location (optional).

Parameters:
uri - A location Path
Returns:
An instance of the builder for method chaining.
Since:
0.8.0

location

public DatasetDescriptor.Builder location(String uri)
                                   throws URISyntaxException
Configure the Dataset's location (optional).

Parameters:
uri - A location String URI
Returns:
An instance of the builder for method chaining.
Throws:
URISyntaxException - if uri is not a valid URI
Since:
0.8.0

property

public DatasetDescriptor.Builder property(String name,
                                          String value)
Add a key-value property to the descriptor.

Parameters:
name - the property name
value - the property value
Returns:
An instance of the builder for method chaining.
Since:
0.8.0

partitionStrategy

public DatasetDescriptor.Builder partitionStrategy(@Nullable
                                                   PartitionStrategy partitionStrategy)
Configure the dataset's partitioning strategy (optional).

Returns:
An instance of the builder for method chaining.

build

public DatasetDescriptor build()
Build an instance of the configured dataset descriptor. Subsequent calls will produce new instances that are similarly configured.

Since:
0.9.0


Copyright © 2013–2014. All rights reserved.