Change number of slices to 1024 (#30990)

* more flexible with some more
This commit is contained in:
Patrik Nordwall 2021-12-15 14:22:03 +01:00 committed by GitHub
parent 6c9c733896
commit 4375fe6bd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View file

@ -449,9 +449,9 @@ class Persistence(val system: ExtendedActorSystem) extends Extension {
* different slice for a persistence id than what was used before, which would
* result in invalid eventsBySlices.
*
* `numberOfSlices` is 128
* `numberOfSlices` is 1024
*/
final def numberOfSlices: Int = 128
final def numberOfSlices: Int = 1024
/**
* A slice is deterministically defined based on the persistence id. The purpose is to
@ -464,8 +464,8 @@ class Persistence(val system: ExtendedActorSystem) extends Extension {
/**
* Scala API: Split the total number of slices into ranges by the given `numberOfRanges`.
*
* For example, `numberOfSlices` is 128 and given 4 `numberOfRanges` this method will
* return ranges (0 to 31), (32 to 63), (64 to 93) and (94 to 127).
* For example, `numberOfSlices` is 1024 and given 4 `numberOfRanges` this method will
* return ranges (0 to 255), (256 to 511), (512 to 767) and (768 to 1023).
*/
final def sliceRanges(numberOfRanges: Int): immutable.IndexedSeq[Range] = {
val rangeSize = numberOfSlices / numberOfRanges
@ -481,7 +481,7 @@ class Persistence(val system: ExtendedActorSystem) extends Extension {
* Java API: Split the total number of slices into ranges by the given `numberOfRanges`.
*
* For example, `numberOfSlices` is 128 and given 4 `numberOfRanges` this method will
* return ranges (0 to 31), (32 to 63), (64 to 93) and (94 to 127).
* return ranges (0 to 255), (256 to 511), (512 to 767) and (768 to 1023).
*/
final def getSliceRanges(numberOfRanges: Int): java.util.List[Pair[Integer, Integer]] = {
import akka.util.ccompat.JavaConverters._

View file

@ -16,7 +16,7 @@ class SliceRangesSpec extends PersistenceSpec(PersistenceSpec.config("inmem", "L
"Persistence slices" must {
"have fixed numberOfSlices" in {
persistence.numberOfSlices should ===(128)
persistence.numberOfSlices should ===(1024)
}
"be deterministic from persistence id" in {
@ -35,13 +35,13 @@ class SliceRangesSpec extends PersistenceSpec(PersistenceSpec.config("inmem", "L
}
"create ranges" in {
persistence.sliceRanges(4) should ===(Vector(0 to 31, 32 to 63, 64 to 95, 96 to 127))
persistence.sliceRanges(1) should ===(Vector(0 to 127))
persistence.sliceRanges(4) should ===(Vector(0 to 255, 256 to 511, 512 to 767, 768 to 1023))
persistence.sliceRanges(1) should ===(Vector(0 to 1023))
}
"create ranges for Java" in {
persistence.getSliceRanges(4) shouldBe
util.Arrays.asList(Pair.create(0, 31), Pair.create(32, 63), Pair.create(64, 95), Pair.create(96, 127))
util.Arrays.asList(Pair.create(0, 255), Pair.create(256, 511), Pair.create(512, 767), Pair.create(768, 1023))
}
}
}