Skip to content

Commit 6f791d4

Browse files
committed
fixed some bugs
1 parent ab035d8 commit 6f791d4

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ require (
2525
github.com/golang-jwt/jwt/v5 v5.2.2
2626
github.com/golang/geo v0.0.0-20250606134707-e8fe6a72b492
2727
github.com/golang/glog v1.2.5
28-
github.com/golang/protobuf v1.5.4
2928
github.com/golang/snappy v1.0.0
3029
github.com/google/codesearch v1.2.0
3130
github.com/google/go-cmp v0.7.0
@@ -108,6 +107,7 @@ require (
108107
github.com/goccy/go-json v0.10.5 // indirect
109108
github.com/gogo/protobuf v1.3.2 // indirect
110109
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
110+
github.com/golang/protobuf v1.5.4 // indirect
111111
github.com/google/flatbuffers v25.2.10+incompatible // indirect
112112
github.com/google/pprof v0.0.0-20250423184734-337e5dd93bb4 // indirect
113113
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect

worker/task.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,13 +2524,17 @@ func (qs *queryState) evaluate(cp countParams, out *pb.Result) error {
25242524

25252525
func (qs *queryState) handleHasWithOrderFunction(ctx context.Context, q *pb.Query, out *pb.Result,
25262526
rev bool, offset, first int) error {
2527+
if first == 0 {
2528+
first = math.MaxInt
2529+
}
2530+
25272531
initKey := x.ParsedKey{
25282532
Attr: q.Attr,
25292533
}
25302534

25312535
startKey := x.IndexKey(q.Attr, "")
25322536
if rev {
2533-
startKey = x.IndexKey(q.Attr, "zzzzzzzzzzzzzzzzzzzzzzzzzzz")
2537+
startKey = x.IndexKeyAfterAllTerms(q.Attr)
25342538
}
25352539

25362540
prefix := initKey.IndexPrefix()

x/keys.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,19 @@ func ReverseKey(attr string, uid uint64) []byte {
231231
return buf
232232
}
233233

234+
func IndexKeyAfterAllTerms(attr string) []byte {
235+
// Use a term with 0xFF to ensure lexicographically after any real term
236+
sentinelTerm := []byte{0xFF}
237+
extra := 1 + len(sentinelTerm) // ByteIndex + 0xFF
238+
buf, prefixLen := generateKey(DefaultPrefix, attr, extra)
239+
240+
rest := buf[prefixLen:]
241+
rest[0] = ByteIndex
242+
copy(rest[1:], sentinelTerm)
243+
244+
return buf
245+
}
246+
234247
// IndexKey generates a index key with the given attribute and term.
235248
// The structure of an index key is as follows:
236249
//

0 commit comments

Comments
 (0)