org.kitesdk.data
Class PartitionStrategy.Builder

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

public static class PartitionStrategy.Builder
extends Object

A fluent builder to aid in the construction of PartitionStrategys.


Constructor Summary
PartitionStrategy.Builder()
           
 
Method Summary
 PartitionStrategy build()
          Build a configured PartitionStrategy instance.
 PartitionStrategy.Builder dateFormat(String sourceName, String name, String format)
          Configure a partitioner that applies a custom date format to a timestamp field.
 PartitionStrategy.Builder day(String sourceName)
          Configure a partitioner for extracting the day from a timestamp field.
 PartitionStrategy.Builder day(String sourceName, String name)
          Configure a partitioner for extracting the day from a timestamp field.
 PartitionStrategy.Builder hash(String sourceName, int buckets)
          Configure a hash partitioner with the specified number of buckets .
 PartitionStrategy.Builder hash(String sourceName, String name, int buckets)
          Configure a hash partitioner with the specified number of buckets .
 PartitionStrategy.Builder hour(String sourceName)
          Configure a partitioner for extracting the hour from a timestamp field.
 PartitionStrategy.Builder hour(String sourceName, String name)
          Configure a partitioner for extracting the hour from a timestamp field.
<S> PartitionStrategy.Builder
identity(String sourceName, Class<S> type, int buckets)
          Deprecated. will be removed in 0.14.0; use identity(String, String, Class, int)
<S> PartitionStrategy.Builder
identity(String sourceName, String name, Class<S> type, int buckets)
          Configure an identity partitioner for a given type with a cardinality hint of buckets size.
 PartitionStrategy.Builder minute(String sourceName)
          Configure a partitioner for extracting the minute from a timestamp field.
 PartitionStrategy.Builder minute(String sourceName, String name)
          Configure a partitioner for extracting the minute from a timestamp field.
 PartitionStrategy.Builder month(String sourceName)
          Configure a partitioner for extracting the month from a timestamp field.
 PartitionStrategy.Builder month(String sourceName, String name)
          Configure a partitioner for extracting the month from a timestamp field.
 PartitionStrategy.Builder range(String sourceName, int... upperBounds)
          Configure a range partitioner with a set of upperBounds.
 PartitionStrategy.Builder range(String sourceName, String... upperBounds)
          Configure a range partitioner for strings with a set of upperBounds.
 PartitionStrategy.Builder year(String sourceName)
          Configure a partitioner for extracting the year from a timestamp field.
 PartitionStrategy.Builder year(String sourceName, String name)
          Configure a partitioner for extracting the year from a timestamp field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PartitionStrategy.Builder

public PartitionStrategy.Builder()
Method Detail

hash

public PartitionStrategy.Builder hash(String sourceName,
                                      int buckets)
Configure a hash partitioner with the specified number of buckets . The partition name is the source field name with a "_hash" suffix. For example, hash("color", 34) creates "color_hash" partitions.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
buckets - The number of buckets into which data is to be partitioned.
Returns:
An instance of the builder for method chaining.

hash

public PartitionStrategy.Builder hash(String sourceName,
                                      String name,
                                      int buckets)
Configure a hash partitioner with the specified number of buckets .

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
name - The entity field name of the partition.
buckets - The number of buckets into which data is to be partitioned.
Returns:
An instance of the builder for method chaining.
Since:
0.3.0

identity

@Deprecated
public <S> PartitionStrategy.Builder identity(String sourceName,
                                                         Class<S> type,
                                                         int buckets)
Deprecated. will be removed in 0.14.0; use identity(String, String, Class, int)

Configure an identity partitioner for a given type with a cardinality hint of buckets size. The partition name is the source field name with a "_copy" suffix. For example, identity("color", String.class, 34) creates "color_copy" partitions.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
type - The type of the field. This must match the schema.
buckets - A hint as to the number of partitions that will be created (i.e. the number of discrete values for the field name in the data).
Returns:
An instance of the builder for method chaining.
Since:
0.8.0
See Also:
IdentityFieldPartitioner

identity

public <S> PartitionStrategy.Builder identity(String sourceName,
                                              String name,
                                              Class<S> type,
                                              int buckets)
Configure an identity partitioner for a given type with a cardinality hint of buckets size.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
name - A name for the partition field
type - The type of the field. This must match the schema.
buckets - A hint as to the number of partitions that will be created (i.e. the number of discrete values for the field name in the data).
Returns:
An instance of the builder for method chaining.
Since:
0.8.0
See Also:
IdentityFieldPartitioner

range

public PartitionStrategy.Builder range(String sourceName,
                                       int... upperBounds)
Configure a range partitioner with a set of upperBounds. The partition name will be the source field name with a "_bound" suffix. For example, range("number", 5, 10) creates "number_bound" partitions.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
upperBounds - A variadic list of upper bounds of each partition.
Returns:
An instance of the builder for method chaining.
See Also:
IntRangeFieldPartitioner

range

public PartitionStrategy.Builder range(String sourceName,
                                       String... upperBounds)
Configure a range partitioner for strings with a set of upperBounds. The partition name will be the source field name with a "_bound" suffix. For example, range("color", "blue", "green") creates "color_bound" partitions.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
upperBounds - A variadic list of upper bounds of each partition.
Returns:
An instance of the builder for method chaining.

year

public PartitionStrategy.Builder year(String sourceName,
                                      String name)
Configure a partitioner for extracting the year from a timestamp field. The UTC timezone is assumed.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
name - The entity field name of the partition.
Returns:
An instance of the builder for method chaining.
Since:
0.3.0

year

public PartitionStrategy.Builder year(String sourceName)
Configure a partitioner for extracting the year from a timestamp field. The UTC timezone is assumed. The partition entity name is "year".

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
Returns:
An instance of the builder for method chaining.
Since:
0.8.0

month

public PartitionStrategy.Builder month(String sourceName,
                                       String name)
Configure a partitioner for extracting the month from a timestamp field. The UTC timezone is assumed.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
name - The entity field name of the partition.
Returns:
An instance of the builder for method chaining.
Since:
0.3.0

month

public PartitionStrategy.Builder month(String sourceName)
Configure a partitioner for extracting the month from a timestamp field. The UTC timezone is assumed. The partition entity name is "month".

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
Returns:
An instance of the builder for method chaining.
Since:
0.8.0

day

public PartitionStrategy.Builder day(String sourceName,
                                     String name)
Configure a partitioner for extracting the day from a timestamp field. The UTC timezone is assumed.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
name - The entity field name of the partition.
Returns:
An instance of the builder for method chaining.
Since:
0.3.0

day

public PartitionStrategy.Builder day(String sourceName)
Configure a partitioner for extracting the day from a timestamp field. The UTC timezone is assumed. The partition entity name is "day".

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
Returns:
An instance of the builder for method chaining.
Since:
0.8.0

hour

public PartitionStrategy.Builder hour(String sourceName,
                                      String name)
Configure a partitioner for extracting the hour from a timestamp field. The UTC timezone is assumed.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
name - The entity field name of the partition.
Returns:
An instance of the builder for method chaining.
Since:
0.3.0

hour

public PartitionStrategy.Builder hour(String sourceName)
Configure a partitioner for extracting the hour from a timestamp field. The UTC timezone is assumed. The partition entity name is "hour".

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
Returns:
An instance of the builder for method chaining.
Since:
0.8.0

minute

public PartitionStrategy.Builder minute(String sourceName,
                                        String name)
Configure a partitioner for extracting the minute from a timestamp field. The UTC timezone is assumed.

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
name - The entity field name of the partition.
Returns:
An instance of the builder for method chaining.
Since:
0.3.0

minute

public PartitionStrategy.Builder minute(String sourceName)
Configure a partitioner for extracting the minute from a timestamp field. The UTC timezone is assumed. The partition entity name is "minute".

Parameters:
sourceName - The entity field name from which to get values to be partitioned.
Returns:
An instance of the builder for method chaining.
Since:
0.8.0

dateFormat

public PartitionStrategy.Builder dateFormat(String sourceName,
                                            String name,
                                            String format)
Configure a partitioner that applies a custom date format to a timestamp field. The UTC timezone is assumed.

Parameters:
sourceName - The entity field name of the timestamp to format
name - A name for the partitions created by the format (e.g. "day")
format - A SimpleDateFormat format-string.
Returns:
This builder for method chaining.
Since:
0.9.0

build

public PartitionStrategy build()
Build a configured PartitionStrategy instance. This builder should be considered single use and discarded after a call to this method.

Returns:
The configured instance of PartitionStrategy.
Since:
0.9.0


Copyright © 2013–2014. All rights reserved.