예제 #1
0
        public override BytesRef Encode(char[] buffer, int offset, int length)
        {
            int payload = ArrayUtil.ParseInt32(buffer, offset, length); //TODO: improve this so that we don't have to new Strings

            byte[]   bytes  = PayloadHelper.EncodeInt32(payload);
            BytesRef result = new BytesRef(bytes);

            return(result);
        }
예제 #2
0
        public override BytesRef Encode(char[] buffer, int offset, int length)
        {
            float payload = float.Parse(new string(buffer, offset, length), CultureInfo.InvariantCulture); //TODO: improve this so that we don't have to new Strings

            byte[]   bytes  = PayloadHelper.EncodeSingle(payload);
            BytesRef result = new BytesRef(bytes);

            return(result);
        }
 public NumericPayloadTokenFilter(TokenStream input, float payload, string typeMatch)
     : base(input)
 {
     if (typeMatch == null)
     {
         throw new ArgumentException("typeMatch cannot be null");
     }
     //Need to encode the payload
     thePayload      = new BytesRef(PayloadHelper.EncodeSingle(payload));
     this.typeMatch  = typeMatch;
     this.payloadAtt = AddAttribute <IPayloadAttribute>();
     this.typeAtt    = AddAttribute <ITypeAttribute>();
 }
예제 #4
0
 public NumericPayloadTokenFilter(TokenStream input, float payload, string typeMatch)
     : base(input)
 {
     if (typeMatch == null)
     {
         throw new ArgumentNullException(nameof(typeMatch), "typeMatch cannot be null"); // LUCENENET specific - changed from IllegalArgumentException to ArgumentNullException (.NET convention)
     }
     //Need to encode the payload
     thePayload      = new BytesRef(PayloadHelper.EncodeSingle(payload));
     this.typeMatch  = typeMatch;
     this.payloadAtt = AddAttribute <IPayloadAttribute>();
     this.typeAtt    = AddAttribute <ITypeAttribute>();
 }
 public override sealed bool IncrementToken()
 {
     if (m_input.IncrementToken())
     {
         byte[] data = new byte[8];
         PayloadHelper.EncodeInt32(offsetAtt.StartOffset, data, 0);
         PayloadHelper.EncodeInt32(offsetAtt.EndOffset, data, 4);
         BytesRef payload = new BytesRef(data);
         payAtt.Payload = payload;
         return(true);
     }
     else
     {
         return(false);
     }
 }