org.apache.lucene.analysis.Token.getPayload()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.lucene.analysis.Token.getPayload()方法的一些代码示例,展示了Token.getPayload()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Token.getPayload()方法的具体详情如下:
包路径:org.apache.lucene.analysis.Token
类名称:Token
方法名:getPayload

Token.getPayload介绍

[英]Returns this Token's payload.
[中]返回此令牌的有效负载。

代码示例

代码示例来源:origin: org.apache.lucene/lucene-analyzers

/**
 * Returns a 32 bit float from the payload, or 1f it null.
 *
 * @param token
 * @return 32 bit float
 */
@Override
public float getWeight(Token token) {
 if (token.getPayload() == null || token.getPayload().getData() == null) {
  return 1f;
 } else {
  return PayloadHelper.decodeFloat(token.getPayload().getData());
 }
}

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

final void writeProx(Token t, FreqProxTermsWriter.PostingList p, int proxCode) {
 final Payload payload = t.getPayload();    
 if (payload != null && payload.length > 0) {
  termsHashPerField.writeVInt(1, (proxCode<<1)|1);
  termsHashPerField.writeVInt(1, payload.length);
  termsHashPerField.writeBytes(1, payload.data, payload.offset, payload.length);
  hasPayloads = true;      
 } else
  termsHashPerField.writeVInt(1, proxCode<<1);
 p.lastPosition = fieldState.position;
}

代码示例来源:origin: org.apache.lucene/lucene-core-jfrog

final void writeProx(Token t, FreqProxTermsWriter.PostingList p, int proxCode) {
 final Payload payload = t.getPayload();    
 if (payload != null && payload.length > 0) {
  termsHashPerField.writeVInt(1, (proxCode<<1)|1);
  termsHashPerField.writeVInt(1, payload.length);
  termsHashPerField.writeBytes(1, payload.data, payload.offset, payload.length);
  hasPayloads = true;      
 } else
  termsHashPerField.writeVInt(1, proxCode<<1);
 p.lastPosition = fieldState.position;
}

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

/** Returns the next token in the stream, or null at EOS.
 *  @deprecated The returned Token is a "full private copy" (not
 *  re-used across calls to next()) but will be slower
 *  than calling {@link #next(Token)} instead.. */
public Token next() throws IOException {
 final Token reusableToken = new Token();
 Token nextToken = next(reusableToken);
 if (nextToken != null) {
  Payload p = nextToken.getPayload();
  if (p != null) {
   nextToken.setPayload((Payload) p.clone());
  }
 }
 return nextToken;
}

代码示例来源:origin: org.apache.lucene/lucene-core-jfrog

/** Returns the next token in the stream, or null at EOS.
 *  @deprecated The returned Token is a "full private copy" (not
 *  re-used across calls to next()) but will be slower
 *  than calling {@link #next(Token)} instead.. */
public Token next() throws IOException {
 final Token reusableToken = new Token();
 Token nextToken = next(reusableToken);
 if (nextToken != null) {
  Payload p = nextToken.getPayload();
  if (p != null) {
   nextToken.setPayload((Payload) p.clone());
  }
 }
 return nextToken;
}

代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core

if (token.getPayload() != null) {
 tokenNamedList.add("payload", token.getPayload());

代码示例来源:origin: org.apache.lucene/lucene-analyzers

@Override
public final boolean incrementToken() throws IOException {
 if (!prefixExhausted) {
  Token nextToken = getNextPrefixInputToken(reusableToken);
  if (nextToken == null) {
   prefixExhausted = true;
  } else {
   previousPrefixToken.reinit(nextToken);
   // Make it a deep copy
   Payload p = previousPrefixToken.getPayload();
   if (p != null) {
    previousPrefixToken.setPayload((Payload) p.clone());
   }
   setCurrentToken(nextToken);
   return true;
  }
 }
 Token nextToken = getNextSuffixInputToken(reusableToken);
 if (nextToken == null) {
  return false;
 }
 nextToken = updateSuffixToken(nextToken, previousPrefixToken);
 setCurrentToken(nextToken);
 return true;
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

@Override
public final boolean incrementToken() throws IOException {
 if (!prefixExhausted) {
  Token nextToken = getNextPrefixInputToken(reusableToken);
  if (nextToken == null) {
   prefixExhausted = true;
  } else {
   previousPrefixToken.reinit(nextToken);
   // Make it a deep copy
   BytesRef p = previousPrefixToken.getPayload();
   if (p != null) {
    previousPrefixToken.setPayload(p.clone());
   }
   setCurrentToken(nextToken);
   return true;
  }
 }
 Token nextToken = getNextSuffixInputToken(reusableToken);
 if (nextToken == null) {
  return false;
 }
 nextToken = updateSuffixToken(nextToken, previousPrefixToken);
 setCurrentToken(nextToken);
 return true;
}

代码示例来源:origin: org.apache.lucene/lucene-analyzers

private void setCurrentToken(Token token) {
 if (token == null) return;
 clearAttributes();
 termAtt.copyBuffer(token.buffer(), 0, token.length());
 posIncrAtt.setPositionIncrement(token.getPositionIncrement());
 flagsAtt.setFlags(token.getFlags());
 offsetAtt.setOffset(token.startOffset(), token.endOffset());
 typeAtt.setType(token.type());
 payloadAtt.setPayload(token.getPayload());
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

private void setCurrentToken(Token token) {
 if (token == null) return;
 clearAttributes();
 termAtt.copyBuffer(token.buffer(), 0, token.length());
 posIncrAtt.setPositionIncrement(token.getPositionIncrement());
 flagsAtt.setFlags(token.getFlags());
 offsetAtt.setOffset(token.startOffset(), token.endOffset());
 typeAtt.setType(token.type());
 payloadAtt.setPayload(token.getPayload());
}

代码示例来源:origin: org.apache.lucene/lucene-analyzers

@Override
public final boolean incrementToken() throws IOException {
 if (matrix == null) {
  matrix = new Matrix();
  // fill matrix with maximumShingleSize columns
  while (matrix.columns.size() < maximumShingleSize && readColumn()) {
   // this loop looks ugly
  }
 }
 // this loop exists in order to avoid recursive calls to the next method
 // as the complexity of a large matrix
 // then would require a multi gigabyte sized stack.
 Token token;
 do {
  token = produceNextToken(reusableToken);
 } while (token == request_next_token);
 if (token == null) return false;
 clearAttributes();
 termAtt.copyBuffer(token.buffer(), 0, token.length());
 posIncrAtt.setPositionIncrement(token.getPositionIncrement());
 flagsAtt.setFlags(token.getFlags());
 offsetAtt.setOffset(token.startOffset(), token.endOffset());
 typeAtt.setType(token.type());
 payloadAtt.setPayload(token.getPayload());
 return true;
}

相关文章