pebble: fix successor

This commit is contained in:
Asdine El Hrychy
2025-09-21 12:45:01 +05:30
parent bc6bba2442
commit b70cae819e
4 changed files with 10 additions and 21 deletions

View File

@@ -40,7 +40,7 @@ $ chai bench -p mydb/ "SELECT 1"
To prepare the database before running a query, use the -i/--init option
$ chai bench -p "CREATE TABLE foo; INSERT INTO foo(a) VALUES (1), (2), (3)" "SELECT * FROM foo"
$ chai bench -i "CREATE TABLE foo(a INT PRIMARY KEY); INSERT INTO foo(a) VALUES (1), (2), (3)" "SELECT * FROM foo"
By default, each query is run in a separate transaction. To run everything, including the setup,
in the same transaction, use -t`,

View File

@@ -94,9 +94,9 @@ func Bench(ctx context.Context, db *sql.DB, query string, opt BenchOptions) erro
err := enc(map[string]interface{}{
"totalQueries": i + opt.SampleSize,
"averageDuration": avg,
"averageDuration": avg.String(),
"queriesPerSecond": qps,
"totalDuration": totalDuration,
"totalDuration": totalDuration.String(),
})
if err != nil {
return err

View File

@@ -265,19 +265,6 @@ func compareNonEmptyValues(t byte, a, b []byte) (cmp int, n int) {
panic(fmt.Sprintf("unsupported value type: %d", a[0]))
}
func Successor(dst, a []byte) []byte {
if len(a) == 0 {
return a
}
namespace, _ := DecodeInt(a)
if namespace == math.MaxInt64 {
return a
}
namespace++
return EncodeInt(dst, namespace)
}
// AbbreviatedKey returns a shortened version that is used for
// comparing keys during indexed batch comparisons.
// The key is not guaranteed to be unique, but it respects the

View File

@@ -114,11 +114,13 @@ var DefaultComparer = &pebble.Comparer{
}
return encoding.Compare(a[an:], b[bn:])
},
Equal: encoding.Equal,
AbbreviatedKey: encoding.AbbreviatedKey,
FormatKey: pebble.DefaultComparer.FormatKey,
Separator: encoding.Separator,
Successor: encoding.Successor,
Equal: encoding.Equal,
AbbreviatedKey: encoding.AbbreviatedKey,
FormatKey: pebble.DefaultComparer.FormatKey,
Separator: encoding.Separator,
Successor: func(dst, a []byte) []byte {
return a
},
Split: encoding.Split,
ComparePointSuffixes: encoding.Compare,
CompareRangeSuffixes: encoding.Compare,