Package org.yamcs.parameterarchive
Class SortedTimeSegment
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
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
-
Method Summary
Modifier and TypeMethodDescriptionint
add
(long instant) Insert instant into the array and return the position at which it has been inserted.int
long[]
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 arraylong
long
long
getTime
(int idx) get timestamp at position idxstatic SortedTimeSegment
parseFrom
(ByteBuffer bb, long segmentStart) int
search
(long instant) performs a binary search in the time segment and returns the position of t or where t would fit in.int
size()
toString()
void
writeTo
(ByteBuffer bb) static void
writeTo
(SortedIntArray tsarray, ByteBuffer bb) Encode the time arrayMethods inherited from class org.yamcs.parameterarchive.BaseSegment
consolidate, 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:
size
in classBaseSegment
-
getSegmentStart
public long getSegmentStart() -
writeTo
- Specified by:
writeTo
in classBaseSegment
-
writeTo
Encode the time array -
parseFrom
public static SortedTimeSegment parseFrom(ByteBuffer bb, long segmentStart) throws DecodingException - Throws:
DecodingException
-
getMaxSerializedSize
public int getMaxSerializedSize()- Specified by:
getMaxSerializedSize
in 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 -
toString
-