Class HistorianProtoCodec
java.lang.Object
com.inductiveautomation.historian.common.protobuf.HistorianProtoCodec
Converts historian model objects to and from their Protocol Buffers messages. It is the one
encoder for each message, shared by the RPC adapters, the store-and-forward serializers and
replication, so the three cannot drift apart.
Timestamps keep sub-millisecond precision across the wire. Paths travel as QualifiedPath.toString() and decode with toQualifiedPath(QualifiedPathPB), which
rejects a string that is not a qualified path.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longEpoch milliseconds written for an absent optional timestamp; any negative value decodes absent.static final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionatomicPointBuilder(AtomicPoint<?> point) Starts anDataPointProto.AtomicPointPBfor a point, for a caller that adds fields of its own.static AnnotationChangePointConverts a message to anAnnotationChangePoint; an absent annotation is a deletion.static AnnotationPointfromAnnotationPB(ComplexPointProto.AnnotationPointPB annotationPB) Converts a message to anAnnotationPoint.static AtomicPoint<?> Converts a message to anAtomicPoint.static AtomicPoint<?> Converts a message to anAtomicPointwith an already-decoded source, so a batch can decode each distinct path once.static BoundingOptionsConverts a message to bounding options; an unset horizon decodes tonull.static ChangePoint<?> Converts a message to theChangePointit carries.static ComplexPoint<?> fromComplexPB(ComplexPointProto.ComplexPointPB complexPB) Converts a message to theComplexPointit carries.static MetadataPointfromMetadataPointPB(ComplexPointProto.MetadataPointPB metadataPB) Converts a message to aMetadataPoint.static @Nullable InstantfromOptionalProtoMilliToInstant(long epochMilli, int subMilliNanos) Decodes an optional wire timestamp.static InstantfromProtoMilliToInstant(long epochMilli, int subMilliNanos) Rebuilds anInstantfrom epoch milliseconds and the nanoseconds fromtoProtoSubMilliNanos(Instant).static SourceChangePointConverts a message to aSourceChangePoint; an absent new source is a retirement.static TimeRangefromTimeRangePB(TimeRangeProto.TimeRangePB timeRangePB) Converts a message to aTimeRange.static AggregatedQueryKeyConverts a message to anAggregatedQueryKey.Converts anAggregatedQueryKeyto its message form.Converts anAnnotationChangePointto its message form.static AnnotationQueryKeyConverts a message to anAnnotationQueryKey.Converts anAnnotationQueryKeyto its message form.Converts anAnnotationPointto its message form.static DataPointProto.AtomicPointPBtoAtomicPointPB(AtomicPoint<?> point) Converts anAtomicPointto its message form.static BasicQualifiedValueConverts a message to a qualified value; a negative timestamp decodes as now.Converts a qualified value to its message form.toBoundingOptionsPB(BoundingOptions bounding) Converts bounding options to their message form.toChangePointPB(ChangePoint<?> point) Converts aChangePointto its message form.toComplexPointPB(ComplexPoint<?> cp) Converts an annotation or metadata point to its message form.toGenericObjectPB(@Nullable Object value) Converts a Java object into aGenericObjectProto.GenericObjectPB.static @Nullable ObjectConverts aGenericObjectProto.GenericObjectPBProtocol Buffers object into a Java object.static MetadataQueryKeyConverts a message to aMetadataQueryKey.Converts aMetadataQueryKeyto its message form.Converts aMetadataPointto its message form.static Map<String, GenericObjectProto.GenericObjectPB> toPropertiesMap(PropertySet data) Converts aPropertySetto encoded properties, omittingnullvalues.static PropertySettoPropertySet(Map<String, GenericObjectProto.GenericObjectPB> propertiesMap) Converts encoded properties to aPropertySet.static inttoProtoSubMilliNanos(Instant instant) Returns the nanosecondsInstant.toEpochMilli()discards, so a timestamp survives a round trip exactly.static QualifiedPathConverts a message to a path.static QualifiedPathtoQualifiedPath(String path) Parses a path written byQualifiedPath.toString().Converts a path to its message form.static QualityCodeConverts a message to a quality code.Converts a quality code, including its diagnostic message, to its message form.Converts aSourceChangePointto its message form.static TimeRangeProto.TimeRangePBtoTimeRangePB(TimeRange timeRange) Converts aTimeRangeto its message form.static TimeWindowtoTimeWindow(TimeWindowProto.TimeWindowPB windowPB) Converts a message to aTimeWindow.static TimeWindowProto.TimeWindowPBtoTimeWindowPB(TimeWindow window) Converts aTimeWindowto its message form.
-
Field Details
-
UNKNOWN_DATA_TYPE
public static final int UNKNOWN_DATA_TYPE- See Also:
-
INSTANT_DATA_TYPE
public static final int INSTANT_DATA_TYPE- See Also:
-
ABSENT_EPOCH_MILLI
public static final long ABSENT_EPOCH_MILLIEpoch milliseconds written for an absent optional timestamp; any negative value decodes absent.- See Also:
-
-
Method Details
-
toGenericObjectPB
public static GenericObjectProto.GenericObjectPB toGenericObjectPB(@Nullable Object value) throws ProtoSerializationException Converts a Java object into aGenericObjectProto.GenericObjectPB.- Parameters:
value- the object to convert; may benull.- Returns:
- the encoded object; a
nullor unmapped type encodes as unknown. - Throws:
ProtoSerializationException- if the object's data type is unsupported.
-
toJavaObject
public static @Nullable Object toJavaObject(GenericObjectProto.GenericObjectPB objectPB) throws ProtoSerializationException Converts aGenericObjectProto.GenericObjectPBProtocol Buffers object into a Java object.- Parameters:
objectPB- TheGenericObjectProto.GenericObjectPBto convert.- Returns:
- The corresponding Java object, or
nullfor an unknown data type. - Throws:
ProtoSerializationException- If the data type is unsupported.
-
toQualifiedPathPB
Converts a path to its message form. -
toQualifiedPath
Converts a message to a path.- Parameters:
pathPB- the message to convert.- Returns:
- the decoded path.
- Throws:
ProtoSerializationException- if the message holds a blank string or not a qualified path.
-
toQualifiedPath
Parses a path written byQualifiedPath.toString().- Parameters:
path- the string to parse.- Returns:
- the decoded path.
- Throws:
ProtoSerializationException- if the string is blank or not a qualified path.
-
toBasicQualifiedValuePB
public static BasicQualifiedValueProto.BasicQualifiedValuePB toBasicQualifiedValuePB(QualifiedValue value) Converts a qualified value to its message form. -
toQualityCodePB
Converts a quality code, including its diagnostic message, to its message form. -
toBasicQualifiedValue
public static BasicQualifiedValue toBasicQualifiedValue(BasicQualifiedValueProto.BasicQualifiedValuePB valuePB) throws ProtoSerializationException Converts a message to a qualified value; a negative timestamp decodes as now.- Parameters:
valuePB- the message to convert.- Returns:
- the decoded value.
- Throws:
ProtoSerializationException- if the value's data type is unsupported.
-
toQualityCode
Converts a message to a quality code. -
fromAnnotationPB
Converts a message to anAnnotationPoint. -
toAnnotationPB
Converts anAnnotationPointto its message form. -
toMetadataPointPB
Converts aMetadataPointto its message form. -
fromMetadataPointPB
Converts a message to aMetadataPoint. -
fromComplexPB
Converts a message to theComplexPointit carries.- Parameters:
complexPB- the message to convert.- Returns:
- the annotation or metadata point.
- Throws:
IllegalArgumentException- if the message carries neither.
-
toComplexPointPB
Converts an annotation or metadata point to its message form.- Parameters:
cp- the point to convert.- Returns:
- the encoded point.
- Throws:
IllegalArgumentException- if the point type is unsupported.
-
fromOptionalProtoMilliToInstant
Decodes an optional wire timestamp.- Parameters:
epochMilli- the epoch milliseconds, or a negative value for absent.subMilliNanos- nanoseconds within that millisecond.- Returns:
- the instant, or
nullif absent.
-
fromProtoMilliToInstant
Rebuilds anInstantfrom epoch milliseconds and the nanoseconds fromtoProtoSubMilliNanos(Instant).- Parameters:
epochMilli- the epoch milliseconds.subMilliNanos- nanoseconds within that millisecond.- Returns:
- the instant.
-
toProtoSubMilliNanos
Returns the nanosecondsInstant.toEpochMilli()discards, so a timestamp survives a round trip exactly.- Parameters:
instant- the instant to split.- Returns:
- nanoseconds within the instant's millisecond,
0..999_999.
-
fromTimeRangePB
Converts a message to aTimeRange. -
toTimeRangePB
Converts aTimeRangeto its message form. -
toBoundingOptionsPB
Converts bounding options to their message form. Horizons travel at millisecond precision; an unset horizon means the receiver's default. -
fromBoundingOptionsPB
Converts a message to bounding options; an unset horizon decodes tonull. -
toPropertySet
public static PropertySet toPropertySet(Map<String, GenericObjectProto.GenericObjectPB> propertiesMap) Converts encoded properties to aPropertySet. -
toPropertiesMap
Converts aPropertySetto encoded properties, omittingnullvalues. -
toTimeWindowPB
Converts aTimeWindowto its message form. -
toTimeWindow
Converts a message to aTimeWindow. -
toMetadataKeyPB
Converts aMetadataQueryKeyto its message form. -
toMetadataKey
Converts a message to aMetadataQueryKey. -
toAnnotationKey
Converts a message to anAnnotationQueryKey. -
toAnnotationKeyPB
Converts anAnnotationQueryKeyto its message form. -
toAggregatedQueryKeyPB
public static DataPointQueryKeysProto.AggregatedQueryKeyPB toAggregatedQueryKeyPB(AggregatedQueryKey any) Converts anAggregatedQueryKeyto its message form. -
toAggregatedQueryKey
public static AggregatedQueryKey toAggregatedQueryKey(DataPointQueryKeysProto.AggregatedQueryKeyPB key) Converts a message to anAggregatedQueryKey.- Parameters:
key- the message to convert.- Returns:
- the decoded key.
- Throws:
ProtoSerializationException- if the source path cannot be parsed.
-
toAtomicPointPB
Converts anAtomicPointto its message form. -
atomicPointBuilder
Starts anDataPointProto.AtomicPointPBfor a point, for a caller that adds fields of its own.- Parameters:
point- the point to encode.- Returns:
- a builder holding every field the point carries.
-
fromAtomicPointPB
Converts a message to anAtomicPoint. -
fromAtomicPointPB
public static AtomicPoint<?> fromAtomicPointPB(DataPointProto.AtomicPointPB pb, QualifiedPath source) Converts a message to anAtomicPointwith an already-decoded source, so a batch can decode each distinct path once.- Parameters:
pb- the message to convert.source- the decodedpb.getSource().- Returns:
- the decoded point.
-
toChangePointPB
Converts aChangePointto its message form. -
fromChangePointPB
Converts a message to theChangePointit carries.- Parameters:
pb- the message to convert.- Returns:
- the source or annotation change.
- Throws:
ProtoSerializationException- if the message carries neither.
-
toSourceChangePointPB
Converts aSourceChangePointto its message form. -
fromSourceChangePointPB
Converts a message to aSourceChangePoint; an absent new source is a retirement. -
toAnnotationChangePointPB
public static ChangePointProto.AnnotationChangePointPB toAnnotationChangePointPB(AnnotationChangePoint point) Converts anAnnotationChangePointto its message form. -
fromAnnotationChangePointPB
public static AnnotationChangePoint fromAnnotationChangePointPB(ChangePointProto.AnnotationChangePointPB pb) Converts a message to anAnnotationChangePoint; an absent annotation is a deletion.
-