net.opentsdb.core
Interface DataPoints

All Superinterfaces:
Iterable<DataPoint>
All Known Subinterfaces:
WritableDataPoints

public interface DataPoints
extends Iterable<DataPoint>

Represents a read-only sequence of continuous data points.

Implementations of this interface aren't expected to be synchronized.


Method Summary
 int aggregatedSize()
          Returns the number of data points aggregated in this instance.
 double doubleValue(int i)
          Returns the value of the ith data point as a float.
 List<String> getAggregatedTags()
          Returns the tags associated with some but not all of the data points.
 Map<String,String> getTags()
          Returns the tags associated with these data points.
 boolean isInteger(int i)
          Tells whether or not the ith value is of integer type.
 SeekableView iterator()
          Returns a zero-copy view to go through size() data points.
 long longValue(int i)
          Returns the value of the ith data point as a long.
 String metricName()
          Returns the name of the series.
 int size()
          Returns the number of data points.
 long timestamp(int i)
          Returns the timestamp associated with the ith data point.
 

Method Detail

metricName

String metricName()
Returns the name of the series.


getTags

Map<String,String> getTags()
Returns the tags associated with these data points.

Returns:
A non-null map of tag names (keys), tag values (values).

getAggregatedTags

List<String> getAggregatedTags()
Returns the tags associated with some but not all of the data points.

When this instance represents the aggregation of multiple time series (same metric but different tags), getTags() returns the tags that are common to all data points (intersection set) whereas this method returns all the tags names that are not common to all data points (union set minus the intersection set, also called the symmetric difference).

If this instance does not represent an aggregation of multiple time series, the list returned is empty.

Returns:
A non-null list of tag names.

size

int size()
Returns the number of data points.

This method must be implemented in O(1) or O(n) where n = aggregatedSize() > 0.

Returns:
A positive integer.

aggregatedSize

int aggregatedSize()
Returns the number of data points aggregated in this instance.

When this instance represents the aggregation of multiple time series (same metric but different tags), size() returns the number of data points after aggregation, whereas this method returns the number of data points before aggregation.

If this instance does not represent an aggregation of multiple time series, then 0 is returned.

Returns:
A positive integer.

iterator

SeekableView iterator()
Returns a zero-copy view to go through size() data points.

The iterator returned must return each DataPoint in O(1). The DataPoint returned must not be stored and gets invalidated as soon as next is called on the iterator. If you want to store individual data points, you need to copy the timestamp and value out of each DataPoint into your own data structures.

Specified by:
iterator in interface Iterable<DataPoint>

timestamp

long timestamp(int i)
Returns the timestamp associated with the ith data point. The first data point has index 0.

This method must be implemented in O(aggregatedSize()) or better.

It is guaranteed that

timestamp(i) < timestamp(i+1)

Returns:
A strictly positive integer.
Throws:
IndexOutOfBoundsException - if i is not in the range [0, size() - 1]

isInteger

boolean isInteger(int i)
Tells whether or not the ith value is of integer type. The first data point has index 0.

This method must be implemented in O(aggregatedSize()) or better.

Returns:
true if the ith value is of integer type, false if it's of floating point type.
Throws:
IndexOutOfBoundsException - if i is not in the range [0, size() - 1]

longValue

long longValue(int i)
Returns the value of the ith data point as a long. The first data point has index 0.

This method must be implemented in O(aggregatedSize()) or better. Use iterator() to get successive O(1) accesses.

Throws:
IndexOutOfBoundsException - if i is not in the range [0, size() - 1]
ClassCastException - if the isInteger(i) == false.
See Also:
iterator()

doubleValue

double doubleValue(int i)
Returns the value of the ith data point as a float. The first data point has index 0.

This method must be implemented in O(aggregatedSize()) or better. Use iterator() to get successive O(1) accesses.

Throws:
IndexOutOfBoundsException - if i is not in the range [0, size() - 1]
ClassCastException - if the isInteger(i) == true.
See Also:
iterator()