(s *search)
| 1409 | } |
| 1410 | |
| 1411 | func (q *SearchQuery) pickCandidateSource(s *search) (src candidateSource) { |
| 1412 | c := q.Constraint |
| 1413 | corpus := s.h.corpus |
| 1414 | if corpus != nil { |
| 1415 | if c.onlyMatchesPermanode() { |
| 1416 | src.sorted = true |
| 1417 | switch q.Sort { |
| 1418 | case LastModifiedDesc: |
| 1419 | src.name = "corpus_permanode_lastmod" |
| 1420 | src.send = func(ctx context.Context, s *search, fn func(camtypes.BlobMeta) bool) error { |
| 1421 | corpus.EnumeratePermanodesLastModified(fn) |
| 1422 | return nil |
| 1423 | } |
| 1424 | return |
| 1425 | case CreatedDesc: |
| 1426 | src.name = "corpus_permanode_created" |
| 1427 | src.send = func(ctx context.Context, s *search, fn func(camtypes.BlobMeta) bool) error { |
| 1428 | corpus.EnumeratePermanodesCreated(fn, true) |
| 1429 | return nil |
| 1430 | } |
| 1431 | return |
| 1432 | default: |
| 1433 | src.sorted = false |
| 1434 | if typs := c.matchesPermanodeTypes(); len(typs) != 0 { |
| 1435 | src.name = "corpus_permanode_types" |
| 1436 | src.send = func(ctx context.Context, s *search, fn func(camtypes.BlobMeta) bool) error { |
| 1437 | corpus.EnumeratePermanodesByNodeTypes(fn, typs) |
| 1438 | return nil |
| 1439 | } |
| 1440 | return |
| 1441 | } |
| 1442 | } |
| 1443 | } |
| 1444 | if br := c.matchesAtMostOneBlob(); br.Valid() { |
| 1445 | src.name = "one_blob" |
| 1446 | src.send = func(ctx context.Context, s *search, fn func(camtypes.BlobMeta) bool) error { |
| 1447 | corpus.EnumerateSingleBlob(fn, br) |
| 1448 | return nil |
| 1449 | } |
| 1450 | return |
| 1451 | } |
| 1452 | // fastpath for files |
| 1453 | if c.matchesFileByWholeRef() { |
| 1454 | src.name = "corpus_file_meta" |
| 1455 | src.send = func(ctx context.Context, s *search, fn func(camtypes.BlobMeta) bool) error { |
| 1456 | corpus.EnumerateCamliBlobs(schema.TypeFile, fn) |
| 1457 | return nil |
| 1458 | } |
| 1459 | return |
| 1460 | } |
| 1461 | if c.AnyCamliType || c.CamliType != "" { |
| 1462 | camType := c.CamliType // empty means all |
| 1463 | src.name = "corpus_blob_meta" |
| 1464 | src.send = func(ctx context.Context, s *search, fn func(camtypes.BlobMeta) bool) error { |
| 1465 | corpus.EnumerateCamliBlobs(camType, fn) |
| 1466 | return nil |
| 1467 | } |
| 1468 | return |
no test coverage detected