Class DateTimeBucketAssigner<IN>

  • All Implemented Interfaces:
    Serializable, BucketAssigner<IN,​String>

    @PublicEvolving
    public class DateTimeBucketAssigner<IN>
    extends Object
    implements BucketAssigner<IN,​String>
    A BucketAssigner that assigns to buckets based on current system time.

    The DateTimeBucketer will create directories of the following form: /{basePath}/{dateTimePath}/. The basePath is the path that was specified as a base path when creating the new bucket. The dateTimePath is determined based on the current system time and the user provided format string.

    DateTimeFormatter is used to derive a date string from the current system time and the date format string. The default format string is "yyyy-MM-dd--HH" so the rolling files will have a granularity of hours.

    Example:

    
     BucketAssigner bucketAssigner = new DateTimeBucketAssigner("yyyy-MM-dd--HH");
     

    This will create for example the following bucket path: /base/1976-12-31-14/

    See Also:
    Serialized Form
    • Constructor Detail

      • DateTimeBucketAssigner

        public DateTimeBucketAssigner()
        Creates a new DateTimeBucketAssigner with format string "yyyy-MM-dd--HH".
      • DateTimeBucketAssigner

        public DateTimeBucketAssigner​(String formatString)
        Creates a new DateTimeBucketAssigner with the given date/time format string.
        Parameters:
        formatString - The format string that will be given to SimpleDateFormat to determine the bucket id.
      • DateTimeBucketAssigner

        public DateTimeBucketAssigner​(ZoneId zoneId)
        Creates a new DateTimeBucketAssigner with format string "yyyy-MM-dd--HH" using the given timezone.
        Parameters:
        zoneId - The timezone used to format DateTimeFormatter for bucket id.
      • DateTimeBucketAssigner

        public DateTimeBucketAssigner​(String formatString,
                                      ZoneId zoneId)
        Creates a new DateTimeBucketAssigner with the given date/time format string using the given timezone.
        Parameters:
        formatString - The format string that will be given to DateTimeFormatter to determine the bucket path.
        zoneId - The timezone used to format DateTimeFormatter for bucket id.