Skip to content

Commit

Permalink
Refactor use of state in TransactionLogPartitionStore
Browse files Browse the repository at this point in the history
  • Loading branch information
patchwork01 committed Feb 21, 2025
1 parent accd2fe commit 2e824d2
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.time.Instant;
import java.time.ZoneId;
import java.util.List;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toUnmodifiableList;

Expand Down Expand Up @@ -59,17 +58,17 @@ public void clearPartitionData() throws StateStoreException {

@Override
public List<Partition> getAllPartitions() throws StateStoreException {
return partitions().collect(toUnmodifiableList());
return partitions().all().stream().toList();
}

@Override
public List<Partition> getLeafPartitions() throws StateStoreException {
return partitions().filter(Partition::isLeafPartition).collect(toUnmodifiableList());
return partitions().all().stream().filter(Partition::isLeafPartition).collect(toUnmodifiableList());
}

@Override
public Partition getPartition(String partitionId) throws StateStoreException {
return state().byId(partitionId)
return partitions().byId(partitionId)
.orElseThrow(() -> new StateStoreException("Partition not found: " + partitionId));
}

Expand Down Expand Up @@ -106,11 +105,7 @@ void applyEntryFromLog(TransactionLogEntry logEntry, StateListenerBeforeApply li
head.applyTransactionUpdatingIfNecessary(logEntry, listener);
}

private Stream<Partition> partitions() throws StateStoreException {
return state().all().stream();
}

private StateStorePartitions state() throws StateStoreException {
private StateStorePartitions partitions() throws StateStoreException {
head.update();
return head.state();
}
Expand Down

0 comments on commit 2e824d2

Please sign in to comment.