mirror of
https://github.com/chaisql/chai.git
synced 2025-09-26 19:51:21 +08:00
pebble: fix successor
This commit is contained in:
@@ -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`,
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user