aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2021-11-12 15:12:30 -0500
committerJonathan Amsterdam <jba@google.com>2021-11-13 12:45:39 +0000
commit80b004f9eaee91c8abe2d8867621ea78cdcc1ee9 (patch)
tree155cb2fbfbd134a4621e0172df3b194a71876f54 /internal/postgres
parent2a0caaa7c7c256ce5f4eb1c65a220df84530a1ef (diff)
downloadgo-x-pkgsite-80b004f9eaee91c8abe2d8867621ea78cdcc1ee9.tar.xz
internal: remove incremental-search experiment
We decided not to proceed with this experiment because incremental search didn't perform well. Change-Id: If3ca6823ad7467b35726ece061694d2153fd29a2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/363736 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
Diffstat (limited to 'internal/postgres')
-rw-r--r--internal/postgres/search.go47
1 files changed, 9 insertions, 38 deletions
diff --git a/internal/postgres/search.go b/internal/postgres/search.go
index 91ca3d4b..460f8f1d 100644
--- a/internal/postgres/search.go
+++ b/internal/postgres/search.go
@@ -8,7 +8,6 @@ import (
"context"
"database/sql"
"fmt"
- "io"
"sort"
"strings"
"time"
@@ -356,45 +355,17 @@ func (db *DB) deepSearch(ctx context.Context, q string, limit int, opts SearchOp
LIMIT $2
OFFSET $3`, scoreExpr)
- var (
- results []*SearchResult
- err error
- )
- if experiment.IsActive(ctx, internal.ExperimentSearchIncrementally) {
- modulePaths := map[string]bool{}
- const pageSize = 10 // TODO(jba): get from elsewhere
- additionalRows := 10 // after reaching pageSize module paths
- collect := func(rows *sql.Rows) error {
- var r SearchResult
- if err := rows.Scan(&r.PackagePath, &r.Version, &r.ModulePath, &r.CommitTime,
- &r.NumImportedBy, &r.Score, &r.NumResults); err != nil {
- return fmt.Errorf("rows.Scan(): %v", err)
- }
- results = append(results, &r)
- // Stop a few rows after we've seen pageSize module paths.
- modulePaths[r.ModulePath] = true
- if len(modulePaths) >= pageSize {
- additionalRows--
- if additionalRows <= 0 {
- return io.EOF
- }
- }
- return nil
- }
- const fetchSize = 20 // number of rows to fetch at a time
- err = db.db.RunQueryIncrementally(ctx, query, fetchSize, collect, q, limit, opts.Offset)
- } else {
- collect := func(rows *sql.Rows) error {
- var r SearchResult
- if err := rows.Scan(&r.PackagePath, &r.Version, &r.ModulePath, &r.CommitTime,
- &r.NumImportedBy, &r.Score, &r.NumResults); err != nil {
- return fmt.Errorf("rows.Scan(): %v", err)
- }
- results = append(results, &r)
- return nil
+ var results []*SearchResult
+ collect := func(rows *sql.Rows) error {
+ var r SearchResult
+ if err := rows.Scan(&r.PackagePath, &r.Version, &r.ModulePath, &r.CommitTime,
+ &r.NumImportedBy, &r.Score, &r.NumResults); err != nil {
+ return fmt.Errorf("rows.Scan(): %v", err)
}
- err = db.db.RunQuery(ctx, query, collect, q, limit, opts.Offset)
+ results = append(results, &r)
+ return nil
}
+ err := db.db.RunQuery(ctx, query, collect, q, limit, opts.Offset)
if err != nil {
results = nil
}