Class PartitionedSequentialKey
- java.lang.Object
-
- org.linuxforhealth.fhir.persistence.util.PartitionedSequentialKey
-
public class PartitionedSequentialKey extends java.lang.Object
A key which contains partition, tstamp and identifier values. This key can be used to track changes being stored in a database. The partition value is used to distribute the keyspace in a partitioned datastore (like Cassandra). This means that jobs needing to scan the keys will need to scan each of the partitions, but this is useful because it's easy to parallelize. The tstamp field is simply the current UTC time. This creates a timeline which can be used to scan records in approximate time-order. Because this is not unique, algorithms such as reconciliation (looking for payloads stored in COS which aren't in the RDBMS) can only checkpoint to the tstamp level, not an individual key. This is OK, because restart from a checkpoint will be rare, and there should be relatively few keys sharing the same tstamp (assuming millisecond accuracy). The identifier is a random UUID and can be assumed to be globally unique.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PartitionedSequentialKey(int partition, long tstamp, java.lang.String resourceType, java.lang.String logicalId, int version)
Protected constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
static PartitionedSequentialKey
generateKey(java.lang.String resourceType, java.lang.String logicalId, int version)
Generate a new instance ofPartitionedSequentialKey
.java.lang.String
getLogicalId()
int
getPartition()
java.lang.String
getResourceType()
long
getTstamp()
int
getVersion()
int
hashCode()
-
-
-
Method Detail
-
generateKey
public static PartitionedSequentialKey generateKey(java.lang.String resourceType, java.lang.String logicalId, int version)
Generate a new instance ofPartitionedSequentialKey
.- Returns:
-
getPartition
public int getPartition()
- Returns:
- the partition
-
getTstamp
public long getTstamp()
- Returns:
- the tstamp
-
getResourceType
public java.lang.String getResourceType()
- Returns:
- the resourceType
-
getLogicalId
public java.lang.String getLogicalId()
- Returns:
- the logicalId
-
getVersion
public int getVersion()
- Returns:
- the version
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-