hachikuji commented on a change in pull request #10206: URL: https://github.com/apache/kafka/pull/10206#discussion_r582568344
########## File path: core/src/main/scala/kafka/coordinator/transaction/TransactionMetadata.scala ########## @@ -25,8 +25,50 @@ import org.apache.kafka.common.record.RecordBatch import scala.collection.{immutable, mutable} + +object TransactionState { + val AllStates = Set( + Empty, + Ongoing, + PrepareCommit, + PrepareAbort, + CompleteCommit, + CompleteAbort, + Dead, + PrepareEpochFence + ) + + def fromName(name: String): Option[TransactionState] = { + name match { + case "Empty" => Some(Empty) + case "Ongoing" => Some(Ongoing) + case "PrepareCommit" => Some(PrepareCommit) + case "PrepareAbort" => Some(PrepareAbort) + case "CompleteCommit" => Some(CompleteCommit) + case "CompleteAbort" => Some(CompleteAbort) + case "PrepareEpochFence" => Some(PrepareEpochFence) + case "Dead" => Some(Dead) + case _ => None + } + } + + def fromId(id: Byte): TransactionState = { Review comment: I left this one as it was since I am not 100% sure whether it has any impact on the performance of transaction loading. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org