MCPcopy
hub / github.com/perkeep/perkeep / GetPermanodesWithAttr

Method GetPermanodesWithAttr

pkg/search/handler.go:575–623  ·  view source on GitHub ↗

GetPermanodesWithAttr returns permanodes with attribute req.Attr having the req.Value as a value. See WithAttrRequest for more details about the query.

(req *WithAttrRequest)

Source from the content-addressed store, hash-verified

573// having the req.Value as a value.
574// See WithAttrRequest for more details about the query.
575func (h *Handler) GetPermanodesWithAttr(req *WithAttrRequest) (*WithAttrResponse, error) {
576 ctx := context.TODO()
577
578 h.index.RLock()
579 defer h.index.RUnlock()
580
581 ch := make(chan blob.Ref, buffered)
582 errch := make(chan error, 1)
583 go func() {
584 signer := req.Signer
585 if !signer.Valid() {
586 signer = h.owner.BlobRef()
587 }
588 errch <- h.index.SearchPermanodesWithAttr(ctx, ch,
589 &camtypes.PermanodeByAttrRequest{
590 Attribute: req.Attr,
591 Query: req.Value,
592 Signer: signer,
593 FuzzyMatch: req.Fuzzy,
594 MaxResults: req.N,
595 At: req.At,
596 })
597 }()
598
599 dr := h.NewDescribeRequest()
600
601 var withAttr []*WithAttrItem
602 for res := range ch {
603 dr.StartDescribe(ctx, res, 2)
604 withAttr = append(withAttr, &WithAttrItem{
605 Permanode: res,
606 })
607 }
608
609 metaMap, err := dr.metaMap()
610 if err != nil {
611 return nil, err
612 }
613
614 if err := <-errch; err != nil {
615 return nil, err
616 }
617
618 res := &WithAttrResponse{
619 WithAttr: withAttr,
620 Meta: metaMap,
621 }
622 return res, nil
623}
624
625// servePermanodesWithAttr uses the indexer to search for the permanodes matching
626// the request.

Callers 1

Calls 8

NewDescribeRequestMethod · 0.95
StartDescribeMethod · 0.95
metaMapMethod · 0.95
RLockMethod · 0.65
RUnlockMethod · 0.65
BlobRefMethod · 0.65
ValidMethod · 0.45

Tested by

no test coverage detected