Skip to content

Commit d4ed581

Browse files
committed
query: allow to always request the size alongside KeysOnly, allow impl to always return the size if no perf cost
1 parent 791ed82 commit d4ed581

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

autobatch/autobatch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
dsq "github.com/ipfs/go-datastore/query"
99
)
1010

11-
// Datastore implements a go-datatsore.
11+
// Datastore implements a go-datastore.
1212
type Datastore struct {
1313
child ds.Batching
1414

query/query.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ type Query struct {
6666
Offset int // skip given number of results
6767
KeysOnly bool // return only keys.
6868
ReturnExpirations bool // return expirations (see TTLDatastore)
69+
ReturnsSize bool // always return sizes. If not set, datastore impl can return
70+
// // it anyway if it doesn't involve a performance cost. If KeysOnly
71+
// // is not set, Size should always be set.
6972
}
7073

7174
// String returns a string represenation of the Query for debugging/validation
@@ -115,9 +118,10 @@ func (q Query) String() string {
115118
// Entry is a query result entry.
116119
type Entry struct {
117120
Key string // cant be ds.Key because circular imports ...!!!
118-
Size int // Might be zero if the datastore doesn't support listing the size with KeysOnly
119121
Value []byte // Will be nil if KeysOnly has been passed.
120122
Expiration time.Time // Entry expiration timestamp if requested and supported (see TTLDatastore).
123+
Size int // Might be -1 if the datastore doesn't support listing the size with KeysOnly
124+
// // or if ReturnsSizes is not set
121125
}
122126

123127
// Result is a special entry that includes an error, so that the client

0 commit comments

Comments
 (0)