java.lang.Object
org.yamcs.parameterarchive.BaseSegment
org.yamcs.parameterarchive.SortedTimeSegment
TimeSegment stores timestamps relative to a segmentStart. The timestamps are stored in a sorted int array.
The timestamps have to be larger than the segmentStart and have to be part of the same interval (see
ParameterArchive.INTERVAL_MASK.
-
Field Summary
FieldsFields inherited from class org.yamcs.parameterarchive.BaseSegment
FORMAT_ID_BinaryValueSegment, FORMAT_ID_BooleanValueSegment, FORMAT_ID_DoubleValueSegment, FORMAT_ID_FloatValueSegment, FORMAT_ID_GenericValueSegment, FORMAT_ID_IntValueSegment, FORMAT_ID_LongValueSegment, FORMAT_ID_ParameterStatusSegment, FORMAT_ID_SortedTimeValueSegment, FORMAT_ID_StringValueSegment, formatId -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintadd(long instant) Insert instant into the array and return the position at which it has been inserted.intlong[]getRange(int posStart, int posStop, boolean ascending) longlonglonggetTime(int idx) get timestamp at position idxstatic SortedTimeSegmentparseFrom(ByteBuffer bb, long segmentStart) intsearch(long instant) performs a binary search in the time segment and returns the position of t or where t would fit in.intsize()toString()voidwriteTo(ByteBuffer bb) Encode the time arrayMethods inherited from class org.yamcs.parameterarchive.BaseSegment
getFormatId, parseSegment
-
Field Details
-
VERSION
public static final int VERSION- See Also:
-
-
Constructor Details
-
SortedTimeSegment
public SortedTimeSegment(long segmentStart)
-
-
Method Details
-
add
public int add(long instant) Insert instant into the array and return the position at which it has been inserted.- Parameters:
instant-
-
getTime
public long getTime(int idx) get timestamp at position idx- Parameters:
idx-- Returns:
-
search
public int search(long instant) performs a binary search in the time segment and returns the position of t or where t would fit in.Note that this works even if the value would not fit in the same interval, which would cause a subsequent add operation to fail.
- Parameters:
instant-- Returns:
- See Also:
-
size
public int size()- Specified by:
sizein classBaseSegment
-
getSegmentStart
public long getSegmentStart() -
writeTo
Encode the time array- Specified by:
writeToin classBaseSegment
-
parseFrom
public static SortedTimeSegment parseFrom(ByteBuffer bb, long segmentStart) throws DecodingException - Throws:
DecodingException
-
getMaxSerializedSize
public int getMaxSerializedSize()- Specified by:
getMaxSerializedSizein classBaseSegment- Returns:
- a high approximation for the serialized size in order to allocate a ByteBuffer big enough
-
getSegmentEnd
public long getSegmentEnd() -
getRange
public long[] getRange(int posStart, int posStop, boolean ascending) -
toString
-