java.lang.Object
org.yamcs.parameterarchive.BaseSegment
org.yamcs.parameterarchive.SortedTimeSegment
TimeSegment stores timestamps relative to the interval start. The timestamps are stored in a sorted int array.
The timestamps 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_GapSegment, FORMAT_ID_GenericValueSegment, FORMAT_ID_IntValueSegment, FORMAT_ID_LongValueSegment, FORMAT_ID_ParameterStatusSegment, FORMAT_ID_SortedTimeValueSegmentV1, FORMAT_ID_SortedTimeValueSegmentV2, 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.longintlong[]getRange(int posStart, int posStop, boolean ascending) long[]getRangeWithGaps(int posStart, int posStop, boolean ascending, SortedIntArray gaps) Get the range between posStart and posStop skipping the positions that are in the gaps arraylonglonglonggetTime(int idx) get timestamp at position idxinthigherBound(long instant) returns idx such thatintlowerBound(long instant) returns idx such thatstatic SortedTimeSegmentparseFromV1(ByteBuffer bb, long segmentStart) static SortedTimeSegmentparseFromV2(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) static voidwriteTo(SortedIntArray tsarray, ByteBuffer bb) Encode the time arrayMethods inherited from class org.yamcs.parameterarchive.BaseSegment
consolidate, getFormatId, makeWritable, parseSegment
-
Field Details
-
VERSION
public static final int VERSION- See Also:
-
-
Constructor Details
-
SortedTimeSegment
public SortedTimeSegment(long interval)
-
-
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:
-
lowerBound
public int lowerBound(long instant) returns idx such thatts[i] >= instant iif i >= idx
-
higherBound
public int higherBound(long instant) returns idx such thatts[i] <= instant iif i <= idx
-
size
public int size()- Specified by:
sizein classBaseSegment
-
getSegmentStart
public long getSegmentStart() -
writeTo
- Specified by:
writeToin classBaseSegment
-
writeTo
Encode the time array -
parseFromV1
public static SortedTimeSegment parseFromV1(ByteBuffer bb, long segmentStart) throws DecodingException - Throws:
DecodingException
-
parseFromV2
public static SortedTimeSegment parseFromV2(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) -
getRangeWithGaps
Get the range between posStart and posStop skipping the positions that are in the gaps array -
getInterval
public long getInterval() -
toString
-