Skip to content

Commit

Permalink
Remove Custom Logic For Archive Querying
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Nov 8, 2024
1 parent 7f87200 commit ecc679f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions plugin/storage/es/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func NewSpanReader(p SpanReaderParams) *SpanReader {
p.Logger,
getTimeRangeIndexFn(p.Archive, p.UseReadWriteAliases, p.RemoteReadClusters),
),
sourceFn: getSourceFn(p.Archive, p.MaxDocCount),
sourceFn: getSourceFn(p.MaxDocCount),
maxDocCount: p.MaxDocCount,
useReadWriteAliases: p.UseReadWriteAliases,
logger: p.Logger,
Expand Down Expand Up @@ -202,16 +202,13 @@ func addRemoteReadClusters(fn timeRangeIndexFn, remoteReadClusters []string) tim
}
}

func getSourceFn(archive bool, maxDocCount int) sourceFn {
func getSourceFn(maxDocCount int) sourceFn {
return func(query elastic.Query, nextTime uint64) *elastic.SearchSource {
s := elastic.NewSearchSource().
return elastic.NewSearchSource().
Query(query).
Size(maxDocCount)
if !archive {
s.Sort("startTime", true).
SearchAfter(nextTime)
}
return s
Size(maxDocCount).
Sort("startTime", true).
SearchAfter(nextTime)
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/es/spanstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ func TestBuildTraceByIDQuery(t *testing.T) {
}

func TestTerminateAfterNotSet(t *testing.T) {
srcFn := getSourceFn(false, 99)
srcFn := getSourceFn(99)
searchSource := srcFn(elastic.NewMatchAllQuery(), 1)
sp, err := searchSource.Source()
require.NoError(t, err)
Expand Down

0 comments on commit ecc679f

Please sign in to comment.