TsukiokaKogane commented on code in PR #62453:
URL: https://github.com/apache/doris/pull/62453#discussion_r3153149165
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/stream/OlapTableStream.java:
##########
@@ -154,4 +164,69 @@ void fillTableStreamConsumptionInfo(List<TRow> dataBatch) {
}
}
}
+
+ public boolean hasData(Partition partition) {
+ // if all available visible data has been consumed, return false
+ // todo(TsukiokaKogane): change offset from partition version to
commit tso
+ return !partitionOffset.containsKey(partition.getId())
+ ||
!partitionOffset.get(partition.getId()).equals(partition.getVisibleVersion())
+ || historicalPartitionOffset.containsKey(partition.getId());
+ }
+
+ public Map<Long, Long> getPartitionOffset(List<Long> selectedPartitionIds)
{
+ if (selectedPartitionIds.isEmpty()) {
+ return null;
+ }
+ Map<Long, Long> result = new HashMap<>(selectedPartitionIds.size());
+ for (Long partitionId : selectedPartitionIds) {
+ if (historicalPartitionOffset.containsKey(partitionId)) {
+ result.put(partitionId,
historicalPartitionOffset.get(partitionId));
+ } else {
+ result.put(partitionId,
partitionOffset.getOrDefault(partitionId, Partition.PARTITION_INIT_VERSION));
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void unprotectedCheckStreamOffset(Map<Long, Long> offset, Map<Long,
Long> nextOffset)
+ throws UserException {
+ // check valid
+ for (Map.Entry<Long, Long> entry : offset.entrySet()) {
+ if (historicalPartitionOffset.containsKey(entry.getKey())) {
+ if
(!historicalPartitionOffset.get(entry.getKey()).equals(entry.getValue())) {
+ throw new TransactionCommitFailedException("history offset
already consumed: "
+ + getDatabase().getId() + '-' + getId() + '-' +
entry.getKey() + '-' + entry.getValue()
+ + " vs " +
historicalPartitionOffset.get(entry.getKey()));
+ }
+ } else if (partitionOffset.containsKey(entry.getKey())) {
+ if
(!partitionOffset.get(entry.getKey()).equals(entry.getValue())) {
+ throw new TransactionCommitFailedException("target offset
already consumed: "
+ + getDatabase().getId() + '-' + getId() + '-' +
entry.getKey() + '-' + entry.getValue()
+ + " vs " + partitionOffset.get(entry.getKey()));
+ }
+ if (nextOffset == null ||
!nextOffset.containsKey(entry.getKey())) {
+ throw new TransactionCommitFailedException(
+ "nextOffset missing for partition=" +
entry.getKey() + ", db=" + getDatabase().getId()
+ + ", stream=" + getId());
+ }
+ } else {
+ // the new partition id may not be updated in time, so key in
table stream not exist is also valid
+ }
+ }
+ }
+
+ @Override
+ public void unprotectedUpdateStreamOffset(Map<Long, Long> offset,
Map<Long, Long> nextOffset, Long ts) {
+ for (Map.Entry<Long, Long> entry : offset.entrySet()) {
+ if (historicalPartitionOffset.containsKey(entry.getKey())) {
+ historicalPartitionOffset.remove(entry.getKey());
+ partitionOffset.put(entry.getKey(), entry.getValue());
+ } else {
+ // todo(TsukiokaKogane): update partition offset
Review Comment:
fixed comment
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]