Class SegmentId

    • Method Detail

      • of

        public static SegmentId of​(String dataSource,
                                   org.joda.time.Interval interval,
                                   String version,
                                   int partitionNum)
      • tryParse

        @Nullable
        public static SegmentId tryParse​(String dataSource,
                                         String segmentId)
        Tries to parse a segment id from the given String representation, or returns null on failure. If returns a non-null SegmentId object, calling toString() on the latter is guaranteed to return a string equal to the argument string of the tryParse() call. It is possible that this method may incorrectly parse a segment id, for example if the dataSource name in the segment id contains a DateTime parseable string such as 'datasource_2000-01-01T00:00:00.000Z' and dataSource was provided as 'datasource'. The desired behavior in this case would be to return null since the identifier does not actually belong to the provided dataSource but a non-null result would be returned. This is an edge case that would currently only affect paged select queries with a union dataSource of two similarly-named dataSources as in the given example. Another source of ambiguity is the end of a segment id like '_123' - it could always be interpreted either as the partitionNum of the segment id, or as the end of the version, with the implicit partitionNum of 0. This method prefers the first iterpretation. To iterate all possible parsings of a segment id, use iteratePossibleParsingsWithDataSource(java.lang.String, java.lang.String).
        Parameters:
        dataSource - the dataSource corresponding to this segment id
        segmentId - segment id
        Returns:
        a SegmentId object if the segment id could be parsed, null otherwise
      • iterateAllPossibleParsings

        public static Iterable<SegmentId> iterateAllPossibleParsings​(String segmentId)
        Returns a (potentially empty) lazy iteration of all possible valid parsings of the given segment id string into SegmentId objects. Warning: most of the parsing work is repeated each time Iterable.iterator() of this iterable is consumed, so it should be consumed only once if possible.
      • iteratePossibleParsingsWithDataSource

        public static List<SegmentId> iteratePossibleParsingsWithDataSource​(String dataSource,
                                                                            String segmentId)
        Returns a list of either 0, 1 or 2 elements containing possible parsings if the given segment id String representation with the given data source name. Returns an empty list when parsing into a valid SegmentId object is impossible. Returns a list of a single element when the given segment id doesn't end with '_[any positive number]', that means that the implicit partitionNum is 0. Otherwise the end of the segment id is interpreted in two ways: with the explicit partitionNum (the first element in the returned list), and with the implicit partitionNum of 0 and the version that ends with '_[any positive number]' (the second element in the returned list).
      • merged

        public static SegmentId merged​(String dataSource,
                                       org.joda.time.Interval interval,
                                       int partitionNum)
        Creates a merged SegmentId for the given data source, interval and partition number. Used when segments are merged.
      • dummy

        public static SegmentId dummy​(String dataSource)
        Creates a dummy SegmentId with the given data source. This method is useful in benchmark and test code.
      • dummy

        public static SegmentId dummy​(String dataSource,
                                      int partitionNum)
        Creates a dummy SegmentId with the given data source and partition number. This method is useful in benchmark and test code.
      • getDataSource

        public String getDataSource()
      • getIntervalStart

        public org.joda.time.DateTime getIntervalStart()
      • getIntervalEnd

        public org.joda.time.DateTime getIntervalEnd()
      • getInterval

        public org.joda.time.Interval getInterval()
      • getVersion

        public String getVersion()
      • getPartitionNum

        public int getPartitionNum()
      • withInterval

        public SegmentId withInterval​(org.joda.time.Interval newInterval)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • safeUpperLimitOfStringSize

        public int safeUpperLimitOfStringSize()