mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-11 07:11:02 +00:00
shorten SetValue_QuickCheck
We reuse a fragment. It might seem surprising that this works, but the fragment code actually doesn't have a persistent bit depth at all, it just accepts whatever bit depth you tell it to use. Cutting out the recreation of the fragments saves some time. We also cap bit depth at 8, instead of 62, because there's a ton of runtime cost to testing more bit depths, but it doesn't actually change the logic.
This commit is contained in:
parent
b2e56a2bc3
commit
5579034eb2
1 changed files with 9 additions and 6 deletions
|
|
@ -384,19 +384,22 @@ func TestFragment_SetValue(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("QuickCheck", func(t *testing.T) {
|
||||
f, idx, tx := mustOpenFragment(t, "i", "f", viewStandard, 0, "")
|
||||
_ = idx
|
||||
defer f.Clean(t)
|
||||
tx.Rollback()
|
||||
|
||||
if err := quick.Check(func(bitDepth uint64, bitN uint64, values []uint64) bool {
|
||||
tx = idx.holder.txf.NewTx(Txo{Write: true, Index: idx, Fragment: f, Shard: f.shard})
|
||||
defer tx.Rollback()
|
||||
// Limit bit depth & maximum values.
|
||||
bitDepth = (bitDepth % 62) + 1
|
||||
bitDepth = (bitDepth % 8) + 1
|
||||
bitN = (bitN % 99) + 1
|
||||
|
||||
for i := range values {
|
||||
values[i] = values[i] % (1 << bitDepth)
|
||||
}
|
||||
|
||||
f, idx, tx := mustOpenFragment(t, "i", "f", viewStandard, 0, "")
|
||||
_ = idx
|
||||
defer f.Clean(t)
|
||||
|
||||
// Set values.
|
||||
m := make(map[uint64]int64)
|
||||
for _, value := range values {
|
||||
|
|
@ -425,7 +428,7 @@ func TestFragment_SetValue(t *testing.T) {
|
|||
if err := tx.Commit(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx = idx.holder.txf.NewTx(Txo{Write: writable, Index: idx, Fragment: f, Shard: f.shard})
|
||||
tx = idx.holder.txf.NewTx(Txo{Write: false, Index: idx, Fragment: f, Shard: f.shard})
|
||||
defer tx.Rollback()
|
||||
|
||||
// Ensure values are set.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue