lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] jregnier commented on issue #477: Fetching a docvalue from the index
Date Thu, 29 Apr 2021 13:47:24 GMT

jregnier commented on issue #477:
URL: https://github.com/apache/lucenenet/issues/477#issuecomment-829252365


   Hello again, So I think I'm getting closer lol, seems like the way to go is to create a
custom ICollector. Below is what I have so far. Am I on the right track so far?
   
   `    public class MyCollector : ICollector
       {
           private readonly OpenBitSet _bits;
           private int _docBase;
           private BinaryDocValues _docValues;
           private HashSet<string> _values;
   
           public MyCollector(OpenBitSet bits)
           {
               _bits = bits ?? throw new ArgumentNullException(nameof(bits));
               _values= new HashSet<string>();
           }
   
           public bool AcceptsDocsOutOfOrder => true;
   
           public void Collect(int doc)
           {
               _bits.Set(doc + _docBase);
   
               if (_docValues== null)
               {
                   return;
               }
   
               var byteRef = new BytesRef();
               _docValues.Get(doc, byteRef);
               _values.Add(byteRef.Utf8ToString());
           }
   
           public void SetNextReader(AtomicReaderContext context)
           {
               _docValues = context.AtomicReader.GetBinaryDocValues("the_value");
               _docBase = context.DocBase;
           }
   
           public void SetScorer(Scorer scorer)
           {
               // We don't care about the score.
           }
       }`
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message