Skip to content

Commit aede048

Browse files
authored
Thread through start and end gcs options to the gcs query (#96)
1 parent 33be8f2 commit aede048

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

google/store.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ func (g *GcsFS) Get(ctx context.Context, objectpath string) (cloudstorage.Object
132132
// If q is nil, no filtering is done.
133133
func (g *GcsFS) Objects(ctx context.Context, csq cloudstorage.Query) (cloudstorage.ObjectIterator, error) {
134134
var q = &storage.Query{Prefix: csq.Prefix}
135+
if csq.StartOffset != "" {
136+
q.StartOffset = csq.StartOffset
137+
}
138+
if csq.EndOffset != "" {
139+
q.EndOffset = csq.EndOffset
140+
}
135141
iter := g.gcsb().Objects(ctx, q)
136142
return &objectIterator{g, ctx, iter}, nil
137143
}

query.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ type Filter func(objects Objects) Objects
1111
// `ls /my-csv-files/baseball/*`. This is the Request, and includes the
1212
// PageSize, cursor/next token as well.
1313
type Query struct {
14-
Delimiter string // Delimiter is most likely "/"
15-
Prefix string // prefix (directory) to search for or object name if one file
16-
Marker string // Next Page Marker if provided is a start next page fetch bookmark.
17-
ShowHidden bool // Show hidden files?
18-
Filters []Filter // Applied to the result sets to filter out Objects (i.e. remove objects by extension)
19-
PageSize int // PageSize defaults to global, or you can supply an override
14+
Delimiter string // Delimiter is most likely "/"
15+
Prefix string // prefix (directory) to search for or object name if one file
16+
StartOffset string // (gcs only) "bar/", Only list objects lexicographically >= "bar/"
17+
EndOffset string // (gcs only) "foo/", Only list objects lexicographically < "foo/"
18+
Marker string // Next Page Marker if provided is a start next page fetch bookmark.
19+
ShowHidden bool // Show hidden files?
20+
Filters []Filter // Applied to the result sets to filter out Objects (i.e. remove objects by extension)
21+
PageSize int // PageSize defaults to global, or you can supply an override
2022
}
2123

2224
// NewQuery create a query for finding files under given prefix.

0 commit comments

Comments
 (0)