Package org.yamcs.parameterarchive
Class SortedTimeSegment
- java.lang.Object
-
- org.yamcs.parameterarchive.BaseSegment
-
- org.yamcs.parameterarchive.SortedTimeSegment
-
public class SortedTimeSegment extends BaseSegment
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 (seeParameterArchive.INTERVAL_MASK.
-
-
Field Summary
Fields Modifier and Type Field Description static intVERSION-
Fields 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 Constructor Description SortedTimeSegment(long segmentStart)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intadd(long instant)Insert instant into the array and return the position at which it has been inserted.intgetMaxSerializedSize()long[]getRange(int posStart, int posStop, boolean ascending)longgetSegmentEnd()longgetSegmentStart()longgetTime(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()StringtoString()voidwriteTo(ByteBuffer bb)Encode the time array-
Methods inherited from class org.yamcs.parameterarchive.BaseSegment
getFormatId, parseSegment
-
-
-
-
Field Detail
-
VERSION
public static final int VERSION
- See Also:
- Constant Field Values
-
-
Method Detail
-
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.- Parameters:
instant-- Returns:
- See Also:
Arrays.binarySearch(int[], int)
-
size
public int size()
- Specified by:
sizein classBaseSegment
-
getSegmentStart
public long getSegmentStart()
-
writeTo
public void writeTo(ByteBuffer bb)
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)
-
-