org.kitesdk.data.partition
Class DateFormatPartitioner

java.lang.Object
  extended by org.kitesdk.data.FieldPartitioner<Long,String>
      extended by org.kitesdk.data.partition.DateFormatPartitioner
All Implemented Interfaces:
com.google.common.base.Function<Long,String>, Comparator<String>

@Beta
public class DateFormatPartitioner
extends FieldPartitioner<Long,String>

A FieldPartitioner that formats a timestamp (long) in milliseconds since epoch, such as those returned by System.currentTimeMillis(), using SimpleDateFormat.

Since:
0.9.0

Constructor Summary
DateFormatPartitioner(String sourceName, String name, String format)
          Construct a new DateFormatPartitioner for Universal Coordinated Time, UTC (+00:00), and cardinality 1095 (3 years, 1 day = 1 partition).
DateFormatPartitioner(String sourceName, String name, String format, int cardinality, TimeZone zone)
          Construct a new DateFormatPartitioner for Universal Coordinated Time, UTC (+00:00).
 
Method Summary
 String apply(Long value)
           Apply the partition function to the given value.
 int compare(String o1, String o2)
           
 boolean equals(Object o)
           
 int hashCode()
           
 com.google.common.base.Predicate<String> project(com.google.common.base.Predicate<Long> predicate)
          Projects a source-data constraint Predicate into the image of the backing partition function.
 String valueFromString(String stringValue)
          Deprecated. 
 
Methods inherited from class org.kitesdk.data.FieldPartitioner
getCardinality, getName, getSourceName, getSourceType, getType, valueToString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatPartitioner

public DateFormatPartitioner(String sourceName,
                             String name,
                             String format)
Construct a new DateFormatPartitioner for Universal Coordinated Time, UTC (+00:00), and cardinality 1095 (3 years, 1 day = 1 partition).

Parameters:
sourceName - Source field name (the field should be a long)
name - Partition name
format - A String format for the SimpleDateFormat constructor

DateFormatPartitioner

public DateFormatPartitioner(String sourceName,
                             String name,
                             String format,
                             int cardinality,
                             TimeZone zone)
Construct a new DateFormatPartitioner for Universal Coordinated Time, UTC (+00:00).

Parameters:
sourceName - Source field name (the field should be a long)
name - Partition name
format - A String format for the SimpleDateFormat constructor
cardinality - A cardinality hint for the number of partitions that will be created by this partitioner. For example, "MM-dd" produces about 365 partitions per year.
Method Detail

apply

public String apply(Long value)
Description copied from class: FieldPartitioner

Apply the partition function to the given value.

The type of value must be compatible with the field partitioner implementation. Normally, this is validated at the time of initial configuration rather than at runtime.

Specified by:
apply in interface com.google.common.base.Function<Long,String>
Specified by:
apply in class FieldPartitioner<Long,String>

valueFromString

@Deprecated
public String valueFromString(String stringValue)
Deprecated. 

Description copied from class: FieldPartitioner

Retrieve the value for the field from the string representation.

Specified by:
valueFromString in class FieldPartitioner<Long,String>

project

public com.google.common.base.Predicate<String> project(com.google.common.base.Predicate<Long> predicate)
Description copied from class: FieldPartitioner
Projects a source-data constraint Predicate into the image of the backing partition function. If the function cannot be projected exactly, the resulting predicate must be more permissive than the original predicate.

Specified by:
project in class FieldPartitioner<Long,String>

compare

public int compare(String o1,
                   String o2)

equals

public boolean equals(Object o)
Specified by:
equals in interface com.google.common.base.Function<Long,String>
Specified by:
equals in interface Comparator<String>
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2013–2014. All rights reserved.