Package org.apache.lucene.index

Examples of org.apache.lucene.index.Payload


      clearAttributes();
      termAtt.setTermBuffer("accents");
      offsetAtt.setOffset(2, 7);
      typeAtt.setType("wrd");
      posIncAtt.setPositionIncrement(3);
      payloadAtt.setPayload(new Payload(new byte[]{0,1,2,3}));
      flagsAtt.setFlags(77);
      return true;
    }
View Full Code Here


  void assertTermEquals(String expected, TokenStream stream, byte[] expectPay) throws Exception {
    TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
    PayloadAttribute payloadAtt = stream.getAttribute(PayloadAttribute.class);
    assertTrue(stream.incrementToken());
    assertEquals(expected, termAtt.term());
    Payload payload = payloadAtt.getPayload();
    if (payload != null) {
      assertTrue(payload.length() + " does not equal: " + expectPay.length, payload.length() == expectPay.length);
      for (int i = 0; i < expectPay.length; i++) {
        assertTrue(expectPay[i] + " does not equal: " + payload.byteAt(i), expectPay[i] == payload.byteAt(i));

      }
    } else {
      assertTrue("expectPay is not null and it should be", expectPay == null);
    }
View Full Code Here


  void assertTermEquals(String expected, TokenStream stream, TermAttribute termAtt, PayloadAttribute payAtt, byte[] expectPay) throws Exception {
    assertTrue(stream.incrementToken());
    assertEquals(expected, termAtt.term());
    Payload payload = payAtt.getPayload();
    if (payload != null) {
      assertTrue(payload.length() + " does not equal: " + expectPay.length, payload.length() == expectPay.length);
      for (int i = 0; i < expectPay.length; i++) {
        assertTrue(expectPay[i] + " does not equal: " + payload.byteAt(i), expectPay[i] == payload.byteAt(i));

      }
    } else {
      assertTrue("expectPay is not null and it should be", expectPay == null);
    }
View Full Code Here

    int count = 0;
    PayloadAttribute payloadAtt = nptf.getAttribute(PayloadAttribute.class);
    OffsetAttribute offsetAtt = nptf.getAttribute(OffsetAttribute.class);
   
    while (nptf.incrementToken()) {
      Payload pay = payloadAtt.getPayload();
      assertTrue("pay is null and it shouldn't be", pay != null);
      byte [] data = pay.getData();
      int start = PayloadHelper.decodeInt(data, 0);
      assertTrue(start + " does not equal: " + offsetAtt.startOffset(), start == offsetAtt.startOffset());
      int end = PayloadHelper.decodeInt(data, 4);
      assertTrue(end + " does not equal: " + offsetAtt.endOffset(), end == offsetAtt.endOffset());
      count++;
View Full Code Here

      if (input.incrementToken()) {
        String token = new String(termAtt.termBuffer(), 0, termAtt.termLength());

        if (!nopayload.contains(token)) {
          if (entities.contains(token)) {
            payloadAtt.setPayload(new Payload((token + ":Entity:"+ pos ).getBytes()));
          } else {
            payloadAtt.setPayload(new Payload((token + ":Noise:" + pos ).getBytes()));
          }
        }
        pos += posIncrAtt.getPositionIncrement();
        return true;
      }
View Full Code Here

  }

  @Override
  public boolean incrementToken() throws IOException {
    if (input.incrementToken()) {
      payloadAttr.setPayload(new Payload(("pos: " + pos).getBytes()));
      int posIncr;
      if (i % 2 == 1) {
        posIncr = 1;
      } else {
        posIncr = 0;
View Full Code Here

            k = ATTRIBUTE_MAPPING.get(k);
          }
         
          // TODO: special handling for payloads - move this to ResponseWriter?
          if (value instanceof Payload) {
            Payload p = (Payload) value;
            if( null != p ) {
              BigInteger bi = new BigInteger( p.getData() );
              String ret = bi.toString( 16 );
              if (ret.length() % 2 != 0) {
                // Pad with 0
                ret = "0"+ret;
              }
View Full Code Here

        long[] values = new long[]{Long.MAX_VALUE,Long.MIN_VALUE,0,1,-1,10,-10,128,-128,127,-127,255,-255,256,-256};

        for (Long value: values) {
       
            LongPayload lPayload = new LongPayload(value);
            Payload payload = lPayload.asPayload();

            LongPayload bPayload = new LongPayload(payload.toByteArray());

            assertEquals(lPayload,bPayload);
            assertEquals(value,bPayload.asLong());
        }
    }
View Full Code Here

          buffer[4] = (byte) (uid >> 32);
          buffer[5] = (byte) (uid >> 40);
          buffer[6] = (byte) (uid >> 48);
          buffer[7] = (byte) (uid >> 56);
          payloadAttr = (PayloadAttribute)addAttribute(PayloadAttribute.class);
          payloadAttr.setPayload(new Payload(buffer));
          termAttr = (TermAttribute)addAttribute(TermAttribute.class);
          termAttr.setTermBuffer(termVal);
          returnToken = true;
        }
View Full Code Here

            if (added) {
                return false;
            }
            termAtt.setLength(0);
            termAtt.append(field.uid);
            payloadAttribute.setPayload(new Payload(Numbers.longToBytes(field.version())));
            added = true;
            return true;
        }
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.Payload

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.