Class ApacheKafkaOffsetPosition
java.lang.Object
com.linkedin.venice.pubsub.adapter.kafka.common.ApacheKafkaOffsetPosition
- All Implemented Interfaces:
Measurable
,PubSubPosition
Offset position for Apache Kafka topics
-
Constructor Summary
ConstructorsConstructorDescriptionApacheKafkaOffsetPosition
(long offset) ApacheKafkaOffsetPosition
(ByteBuffer buffer) -
Method Summary
Modifier and TypeMethodDescriptionint
comparePosition
(PubSubPosition other) long
diff
(PubSubPosition other) boolean
int
long
long
Returns an Avro-encoded wire format representation of this position, including both the position type ID and the raw Avro-encoded bytes representing the position value.int
hashCode()
static ApacheKafkaOffsetPosition
of
(long offset) static ApacheKafkaOffsetPosition
of
(ByteBuffer buffer) toString()
-
Constructor Details
-
ApacheKafkaOffsetPosition
public ApacheKafkaOffsetPosition(long offset) -
ApacheKafkaOffsetPosition
- Parameters:
buffer
- the buffer to read from. The ByteBuffer expected to contain avro serialized long- Throws:
IOException
- if the buffer is not a valid avro serialized long
-
-
Method Details
-
comparePosition
- Specified by:
comparePosition
in interfacePubSubPosition
- Parameters:
other
- the other position to compare to- Returns:
- returns 0 if the positions are equal, -1 if this position is less than the other position, and 1 if this position is greater than the other position
-
diff
- Specified by:
diff
in interfacePubSubPosition
- Returns:
- the difference between this position and the other position
- Throws:
IllegalArgumentException
- if position is null or positions are not comparable
-
getOffset
public long getOffset() -
toString
-
equals
- Specified by:
equals
in interfacePubSubPosition
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfacePubSubPosition
- Overrides:
hashCode
in classObject
-
getNumericOffset
public long getNumericOffset()- Specified by:
getNumericOffset
in interfacePubSubPosition
-
of
-
of
- Throws:
IOException
-
getPositionWireFormat
Returns an Avro-encoded wire format representation of this position, including both the position type ID and the raw Avro-encoded bytes representing the position value. This is used to transmitPubSubPosition
instances over the wire.Example (ApacheKafkaOffsetPosition):
+-------------------------+ | Avro-encoded int: type | (e.g., 0) +-------------------------+ | Avro-encoded bytes: | (Avro-encoded long offset) | rawBytes | +-------------------------+
- Specified by:
getPositionWireFormat
in interfacePubSubPosition
- Returns:
- the serialized
PubSubPositionWireFormat
containing the type and position bytes
-
getHeapSize
public int getHeapSize()- Specified by:
getHeapSize
in interfaceMeasurable
-