当前位置: 首页>>代码示例>>Java>>正文


Java BlockTermState类代码示例

本文整理汇总了Java中org.apache.lucene.codecs.BlockTermState的典型用法代码示例。如果您正苦于以下问题:Java BlockTermState类的具体用法?Java BlockTermState怎么用?Java BlockTermState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BlockTermState类属于org.apache.lucene.codecs包,在下文中一共展示了BlockTermState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeTerm

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public void encodeTerm(long[] longs, DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException {
  IntBlockTermState state = (IntBlockTermState)_state;
  if (absolute) {
    lastState = emptyState;
  }
  longs[0] = state.docStartFP - lastState.docStartFP;
  if (fieldHasPositions) {
    longs[1] = state.posStartFP - lastState.posStartFP;
    if (fieldHasPayloads || fieldHasOffsets) {
      longs[2] = state.payStartFP - lastState.payStartFP;
    }
  }
  if (state.singletonDocID != -1) {
    out.writeVInt(state.singletonDocID);
  }
  if (fieldHasPositions) {
    if (state.lastPosBlockOffset != -1) {
      out.writeVLong(state.lastPosBlockOffset);
    }
  }
  if (state.skipOffset != -1) {
    out.writeVLong(state.skipOffset);
  }
  lastState = state;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:Lucene41PostingsWriter.java

示例2: finishTerm

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public void finishTerm(BytesRef text, TermStats stats) throws IOException {
  // write term meta data into fst
  final BlockTermState state = postingsWriter.newTermState();
  final FSTTermOutputs.TermData meta = new FSTTermOutputs.TermData();
  meta.longs = new long[longsSize];
  meta.bytes = null;
  meta.docFreq = state.docFreq = stats.docFreq;
  meta.totalTermFreq = state.totalTermFreq = stats.totalTermFreq;
  postingsWriter.finishTerm(state);
  postingsWriter.encodeTerm(meta.longs, metaWriter, fieldInfo, state, true);
  final int bytesSize = (int)metaWriter.getFilePointer();
  if (bytesSize > 0) {
    meta.bytes = new byte[bytesSize];
    metaWriter.writeTo(meta.bytes, 0);
    metaWriter.reset();
  }
  builder.add(Util.toIntsRef(text, scratchTerm), meta);
  numTerms++;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:FSTTermsWriter.java

示例3: docs

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public DocsEnum docs(FieldInfo fieldInfo, BlockTermState _termState, Bits liveDocs, DocsEnum reuse, int flags) throws IOException {
  final SepTermState termState = (SepTermState) _termState;
  SepDocsEnum docsEnum;
  if (reuse == null || !(reuse instanceof SepDocsEnum)) {
    docsEnum = new SepDocsEnum();
  } else {
    docsEnum = (SepDocsEnum) reuse;
    if (docsEnum.startDocIn != docIn) {
      // If you are using ParellelReader, and pass in a
      // reused DocsAndPositionsEnum, it could have come
      // from another reader also using sep codec
      docsEnum = new SepDocsEnum();        
    }
  }

  return docsEnum.init(fieldInfo, termState, liveDocs);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:SepPostingsReader.java

示例4: docsAndPositions

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public DocsAndPositionsEnum docsAndPositions(FieldInfo fieldInfo, BlockTermState _termState, Bits liveDocs,
                                             DocsAndPositionsEnum reuse, int flags)
  throws IOException {

  assert fieldInfo.getIndexOptions() == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
  final SepTermState termState = (SepTermState) _termState;
  SepDocsAndPositionsEnum postingsEnum;
  if (reuse == null || !(reuse instanceof SepDocsAndPositionsEnum)) {
    postingsEnum = new SepDocsAndPositionsEnum();
  } else {
    postingsEnum = (SepDocsAndPositionsEnum) reuse;
    if (postingsEnum.startDocIn != docIn) {
      // If you are using ParellelReader, and pass in a
      // reused DocsAndPositionsEnum, it could have come
      // from another reader also using sep codec
      postingsEnum = new SepDocsAndPositionsEnum();        
    }
  }

  return postingsEnum.init(fieldInfo, termState, liveDocs);
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:SepPostingsReader.java

示例5: encodeTerm

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public void encodeTerm(long[] empty, DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException {
  PulsingTermState state = (PulsingTermState)_state;
  assert empty.length == 0;
  this.absolute = this.absolute || absolute;
  if (state.bytes == null) {
    wrappedPostingsWriter.encodeTerm(longs, buffer, fieldInfo, state.wrappedState, this.absolute);
    for (int i = 0; i < longsSize; i++) {
      out.writeVLong(longs[i]);
    }
    buffer.writeTo(out);
    buffer.reset();
    this.absolute = false;
  } else {
    out.writeVInt(state.bytes.length);
    out.writeBytes(state.bytes, 0, state.bytes.length);
    this.absolute = this.absolute || absolute;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:PulsingPostingsWriter.java

示例6: finishTerm

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
/** Called when we are done adding docs to this term */
@Override
public void finishTerm(BlockTermState _state) throws IOException {
  StandardTermState state = (StandardTermState)_state;
  // if (DEBUG) System.out.println("SPW: finishTerm seg=" + segment + " freqStart=" + freqStart);
  assert state.docFreq > 0;

  // TODO: wasteful we are counting this (counting # docs
  // for this term) in two places?
  assert state.docFreq == df;
  state.freqStart = freqStart;
  state.proxStart = proxStart;
  if (df >= skipMinimum) {
    state.skipOffset = skipListWriter.writeSkip(freqOut)-freqStart;
  } else {
    state.skipOffset = -1;
  }
  lastDocID = 0;
  df = 0;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:Lucene40PostingsWriter.java

示例7: encodeTerm

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public void encodeTerm(long[] empty, DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException {
  StandardTermState state = (StandardTermState)_state;
  if (absolute) {
    lastState = emptyState;
  }
  out.writeVLong(state.freqStart - lastState.freqStart);
  if (state.skipOffset != -1) {
    assert state.skipOffset > 0;
    out.writeVLong(state.skipOffset);
  }
  if (indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
    out.writeVLong(state.proxStart - lastState.proxStart);
  }
  lastState = state;
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:Lucene40PostingsWriter.java

示例8: readTermsBlock

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public void readTermsBlock(IndexInput termsIn, FieldInfo fieldInfo, BlockTermState _termState) throws IOException {
  //System.out.println("PR.readTermsBlock state=" + _termState);
  final PulsingTermState termState = (PulsingTermState) _termState;
  if (termState.inlinedBytes == null) {
    termState.inlinedBytes = new byte[128];
    termState.inlinedBytesReader = new ByteArrayDataInput();
  }
  int len = termsIn.readVInt();
  //System.out.println("  len=" + len + " fp=" + termsIn.getFilePointer());
  if (termState.inlinedBytes.length < len) {
    termState.inlinedBytes = new byte[ArrayUtil.oversize(len, 1)];
  }
  termsIn.readBytes(termState.inlinedBytes, 0, len);
  termState.inlinedBytesReader.reset(termState.inlinedBytes);
  termState.wrappedTermState.termBlockOrd = 0;
  wrappedPostingsReader.readTermsBlock(termsIn, fieldInfo, termState.wrappedTermState);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:PulsingPostingsReader.java

示例9: readTermsBlock

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public void readTermsBlock(IndexInput termsIn, FieldInfo fieldInfo, BlockTermState _termState) throws IOException {
  final StandardTermState termState = (StandardTermState) _termState;

  final int len = termsIn.readVInt();

  // if (DEBUG) System.out.println("  SPR.readTermsBlock bytes=" + len + " ts=" + _termState);
  if (termState.bytes == null) {
    termState.bytes = new byte[ArrayUtil.oversize(len, 1)];
    termState.bytesReader = new ByteArrayDataInput();
  } else if (termState.bytes.length < len) {
    termState.bytes = new byte[ArrayUtil.oversize(len, 1)];
  }

  termsIn.readBytes(termState.bytes, 0, len);
  termState.bytesReader.reset(termState.bytes, 0, len);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:18,代码来源:Lucene40PostingsReader.java

示例10: readTermsBlock

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public void readTermsBlock(IndexInput termsIn, FieldInfo fieldInfo, BlockTermState _termState) throws IOException {
  final IntBlockTermState termState = (IntBlockTermState) _termState;

  final int numBytes = termsIn.readVInt();

  if (termState.bytes == null) {
    termState.bytes = new byte[ArrayUtil.oversize(numBytes, 1)];
    termState.bytesReader = new ByteArrayDataInput();
  } else if (termState.bytes.length < numBytes) {
    termState.bytes = new byte[ArrayUtil.oversize(numBytes, 1)];
  }

  termsIn.readBytes(termState.bytes, 0, numBytes);
  termState.bytesReader.reset(termState.bytes, 0, numBytes);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:Lucene41PostingsReader.java

示例11: decodeTerm

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public void decodeTerm(long[] longs, DataInput in, FieldInfo fieldInfo, BlockTermState _termState, boolean absolute)
  throws IOException {
  final StandardTermState termState = (StandardTermState) _termState;
  // if (DEBUG) System.out.println("SPR: nextTerm seg=" + segment + " tbOrd=" + termState.termBlockOrd + " bytesReader.fp=" + termState.bytesReader.getPosition());
  final boolean isFirstTerm = termState.termBlockOrd == 0;
  if (absolute) {
    termState.freqOffset = 0;
    termState.proxOffset = 0;
  }

  termState.freqOffset += in.readVLong();
  /*
  if (DEBUG) {
    System.out.println("  dF=" + termState.docFreq);
    System.out.println("  freqFP=" + termState.freqOffset);
  }
  */
  assert termState.freqOffset < freqIn.length();

  if (termState.docFreq >= skipMinimum) {
    termState.skipOffset = in.readVLong();
    // if (DEBUG) System.out.println("  skipOffset=" + termState.skipOffset + " vs freqIn.length=" + freqIn.length());
    assert termState.freqOffset + termState.skipOffset < freqIn.length();
  } else {
    // undefined
  }

  if (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
    termState.proxOffset += in.readVLong();
    // if (DEBUG) System.out.println("  proxFP=" + termState.proxOffset);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:Lucene40PostingsReader.java

示例12: docs

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public DocsEnum docs(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, DocsEnum reuse, int flags) throws IOException {
  if (canReuse(reuse, liveDocs)) {
    // if (DEBUG) System.out.println("SPR.docs ts=" + termState);
    return ((SegmentDocsEnumBase) reuse).reset(fieldInfo, (StandardTermState)termState);
  }
  return newDocsEnum(liveDocs, fieldInfo, (StandardTermState)termState);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:Lucene40PostingsReader.java

示例13: docs

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public DocsEnum docs(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, DocsEnum reuse, int flags) throws IOException {
  BlockDocsEnum docsEnum;
  if (reuse instanceof BlockDocsEnum) {
    docsEnum = (BlockDocsEnum) reuse;
    if (!docsEnum.canReuse(docIn, fieldInfo)) {
      docsEnum = new BlockDocsEnum(fieldInfo);
    }
  } else {
    docsEnum = new BlockDocsEnum(fieldInfo);
  }
  return docsEnum.reset(liveDocs, (IntBlockTermState) termState, flags);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:Lucene41PostingsReader.java

示例14: docsAndPositions

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public DocsAndPositionsEnum docsAndPositions(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs,
                                             DocsAndPositionsEnum reuse, int flags)
  throws IOException {

  boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
  boolean indexHasPayloads = fieldInfo.hasPayloads();

  if ((!indexHasOffsets || (flags & DocsAndPositionsEnum.FLAG_OFFSETS) == 0) &&
      (!indexHasPayloads || (flags & DocsAndPositionsEnum.FLAG_PAYLOADS) == 0)) {
    BlockDocsAndPositionsEnum docsAndPositionsEnum;
    if (reuse instanceof BlockDocsAndPositionsEnum) {
      docsAndPositionsEnum = (BlockDocsAndPositionsEnum) reuse;
      if (!docsAndPositionsEnum.canReuse(docIn, fieldInfo)) {
        docsAndPositionsEnum = new BlockDocsAndPositionsEnum(fieldInfo);
      }
    } else {
      docsAndPositionsEnum = new BlockDocsAndPositionsEnum(fieldInfo);
    }
    return docsAndPositionsEnum.reset(liveDocs, (IntBlockTermState) termState);
  } else {
    EverythingEnum everythingEnum;
    if (reuse instanceof EverythingEnum) {
      everythingEnum = (EverythingEnum) reuse;
      if (!everythingEnum.canReuse(docIn, fieldInfo)) {
        everythingEnum = new EverythingEnum(fieldInfo);
      }
    } else {
      everythingEnum = new EverythingEnum(fieldInfo);
    }
    return everythingEnum.reset(liveDocs, (IntBlockTermState) termState, flags);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:Lucene41PostingsReader.java

示例15: finishTerm

import org.apache.lucene.codecs.BlockTermState; //导入依赖的package包/类
@Override
public void finishTerm(BytesRef text, TermStats stats) throws IOException {
  if (numTerms > 0 && numTerms % SKIP_INTERVAL == 0) {
    bufferSkip();
  }
  // write term meta data into fst
  final long longs[] = new long[longsSize];
  final long delta = stats.totalTermFreq - stats.docFreq;
  if (stats.totalTermFreq > 0) {
    if (delta == 0) {
      statsOut.writeVInt(stats.docFreq<<1|1);
    } else {
      statsOut.writeVInt(stats.docFreq<<1|0);
      statsOut.writeVLong(stats.totalTermFreq-stats.docFreq);
    }
  } else {
    statsOut.writeVInt(stats.docFreq);
  }
  BlockTermState state = postingsWriter.newTermState();
  state.docFreq = stats.docFreq;
  state.totalTermFreq = stats.totalTermFreq;
  postingsWriter.finishTerm(state);
  postingsWriter.encodeTerm(longs, metaBytesOut, fieldInfo, state, true);
  for (int i = 0; i < longsSize; i++) {
    metaLongsOut.writeVLong(longs[i] - lastLongs[i]);
    lastLongs[i] = longs[i];
  }
  metaLongsOut.writeVLong(metaBytesOut.getFilePointer() - lastMetaBytesFP);

  builder.add(Util.toIntsRef(text, scratchTerm), numTerms);
  numTerms++;

  lastMetaBytesFP = metaBytesOut.getFilePointer();
}
 
开发者ID:europeana,项目名称:search,代码行数:35,代码来源:FSTOrdTermsWriter.java


注:本文中的org.apache.lucene.codecs.BlockTermState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。